mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add alias and display name to document people.
This commit is contained in:
8202
Cicm.Database/Migrations/20190630212811_AddDisplayNameAndAliasToDocumentPerson.Designer.cs
generated
Normal file
8202
Cicm.Database/Migrations/20190630212811_AddDisplayNameAndAliasToDocumentPerson.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace Cicm.Database.Migrations
|
||||||
|
{
|
||||||
|
public partial class AddDisplayNameAndAliasToDocumentPerson : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>("Alias", "DocumentPeople", nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>("DisplayName", "DocumentPeople", nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_DocumentPeople_Alias", "DocumentPeople", "Alias");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_DocumentPeople_DisplayName", "DocumentPeople", "DisplayName");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropIndex("IX_DocumentPeople_Alias", "DocumentPeople");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex("IX_DocumentPeople_DisplayName", "DocumentPeople");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn("Alias", "DocumentPeople");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn("DisplayName", "DocumentPeople");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -398,6 +398,10 @@ namespace Cicm.Database.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<int>("Id").ValueGeneratedOnAdd();
|
b.Property<int>("Id").ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<string>("Alias");
|
||||||
|
|
||||||
|
b.Property<string>("DisplayName");
|
||||||
|
|
||||||
b.Property<string>("Name").IsRequired();
|
b.Property<string>("Name").IsRequired();
|
||||||
|
|
||||||
b.Property<int?>("PersonId");
|
b.Property<int?>("PersonId");
|
||||||
@@ -406,6 +410,10 @@ namespace Cicm.Database.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("Alias");
|
||||||
|
|
||||||
|
b.HasIndex("DisplayName");
|
||||||
|
|
||||||
b.HasIndex("Name");
|
b.HasIndex("Name");
|
||||||
|
|
||||||
b.HasIndex("PersonId").IsUnique();
|
b.HasIndex("PersonId").IsUnique();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
@@ -9,15 +10,19 @@ namespace Cicm.Database.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Surname { get; set; }
|
public string Surname { get; set; }
|
||||||
public int? PersonId { get; set; }
|
public int? PersonId { get; set; }
|
||||||
|
public string Alias { get; set; }
|
||||||
|
[DisplayName("Name to be displayed")]
|
||||||
|
public string DisplayName { get; set; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
[DisplayName("Name")]
|
||||||
|
public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}";
|
||||||
|
|
||||||
public virtual Person Person { get; set; }
|
public virtual Person Person { get; set; }
|
||||||
public virtual ICollection<PeopleByDocument> Documents { get; set; }
|
public virtual ICollection<PeopleByDocument> Documents { get; set; }
|
||||||
public virtual ICollection<PeopleByBook> Books { get; set; }
|
public virtual ICollection<PeopleByBook> Books { get; set; }
|
||||||
public virtual ICollection<PeopleByMagazine> Magazines { get; set; }
|
public virtual ICollection<PeopleByMagazine> Magazines { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
|
||||||
public string FullName => $"{Name} {Surname}";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -398,6 +398,10 @@ namespace Cicm.Database.Models
|
|||||||
|
|
||||||
entity.HasIndex(e => e.PersonId).IsUnique();
|
entity.HasIndex(e => e.PersonId).IsUnique();
|
||||||
|
|
||||||
|
entity.HasIndex(e => e.Alias);
|
||||||
|
|
||||||
|
entity.HasIndex(e => e.DisplayName);
|
||||||
|
|
||||||
entity.HasOne(d => d.Person).WithOne(p => p.DocumentPerson)
|
entity.HasOne(d => d.Person).WithOne(p => p.DocumentPerson)
|
||||||
.HasForeignKey<Person>(d => d.DocumentPersonId).OnDelete(DeleteBehavior.SetNull);
|
.HasForeignKey<Person>(d => d.DocumentPersonId).OnDelete(DeleteBehavior.SetNull);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
<Version>3.0.99.875</Version>
|
<Version>3.0.99.881</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user