Add document people.

This commit is contained in:
2019-06-17 00:28:17 +01:00
parent f9f347937a
commit e2c9416bbe
7 changed files with 7676 additions and 11 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class AddDocumentPeople : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>("DocumentPersonId", "People", nullable: true);
migrationBuilder.CreateTable("DocumentPeople",
table => new
{
Id = table.Column<int>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(),
Surname = table.Column<string>(),
PersonId = table.Column<int>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_DocumentPeople", x => x.Id);
table.ForeignKey("FK_DocumentPeople_People_PersonId", x => x.PersonId,
"People", "Id", onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateIndex("IX_DocumentPeople_Name", "DocumentPeople", "Name");
migrationBuilder.CreateIndex("IX_DocumentPeople_PersonId", "DocumentPeople", "PersonId", unique: true);
migrationBuilder.CreateIndex("IX_DocumentPeople_Surname", "DocumentPeople", "Surname");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("DocumentPeople");
migrationBuilder.DropColumn("DocumentPersonId", "People");
}
}
}

View File

@@ -229,6 +229,27 @@ namespace Cicm.Database.Migrations
b.ToTable("Documents");
});
modelBuilder.Entity("Cicm.Database.Models.DocumentPerson", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<string>("Name").IsRequired();
b.Property<int?>("PersonId");
b.Property<string>("Surname").IsRequired();
b.HasKey("Id");
b.HasIndex("Name");
b.HasIndex("PersonId").IsUnique();
b.HasIndex("Surname");
b.ToTable("DocumentPeople");
});
modelBuilder.Entity("Cicm.Database.Models.DocumentRole", b =>
{
b.Property<string>("Id").ValueGeneratedOnAdd().HasColumnType("char(3)");
@@ -4577,6 +4598,8 @@ namespace Cicm.Database.Migrations
b.Property<DateTime?>("DeathDate");
b.Property<int?>("DocumentPersonId");
b.Property<string>("Facebook");
b.Property<string>("Name").IsRequired();
@@ -5203,6 +5226,14 @@ namespace Cicm.Database.Migrations
.HasForeignKey("CountryId");
});
modelBuilder.Entity("Cicm.Database.Models.DocumentPerson",
b =>
{
b.HasOne("Cicm.Database.Models.Person", "Person").WithOne("DocumentPerson")
.HasForeignKey("Cicm.Database.Models.DocumentPerson", "PersonId")
.OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity("Cicm.Database.Models.Gpu",
b =>
{

View File

@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Cicm.Database.Models
{
public class DocumentPerson : BaseModel<int>
{
[Required]
public string Name { get; set; }
[Required]
public string Surname { get; set; }
public int? PersonId { get; set; }
public virtual Person Person { get; set; }
[NotMapped]
public string FullName => $"{Name} {Surname}";
}
}

View File

@@ -10,19 +10,21 @@ namespace Cicm.Database.Models
[Required]
public string Name { get; set; }
[Required]
public string Surname { get; set; }
public virtual Iso31661Numeric CountryOfBirth { get; set; }
public DateTime BirthDate { get; set; }
public DateTime? DeathDate { get; set; }
public string Webpage { get; set; }
public string Twitter { get; set; }
public string Facebook { get; set; }
public Guid Photo { get; set; }
public string Surname { get; set; }
public virtual Iso31661Numeric CountryOfBirth { get; set; }
public DateTime BirthDate { get; set; }
public DateTime? DeathDate { get; set; }
public string Webpage { get; set; }
public string Twitter { get; set; }
public string Facebook { get; set; }
public Guid Photo { get; set; }
public int? DocumentPersonId { get; set; }
[NotMapped]
public string FullName => $"{Name} {Surname}";
public short? CountryOfBirthId { get; set; }
public virtual ICollection<PeopleByCompany> Companies { get; set; }
public short? CountryOfBirthId { get; set; }
public virtual ICollection<PeopleByCompany> Companies { get; set; }
public virtual DocumentPerson DocumentPerson { get; set; }
}
}

View File

@@ -80,6 +80,7 @@ namespace Cicm.Database.Models
public virtual DbSet<Iso639> Iso639 { get; set; }
public virtual DbSet<Document> Documents { get; set; }
public virtual DbSet<DocumentRole> DocumentRoles { get; set; }
public virtual DbSet<DocumentPerson> DocumentPeople { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -276,6 +277,18 @@ namespace Cicm.Database.Models
entity.HasOne(d => d.Country).WithMany(p => p.Documents).HasForeignKey(d => d.CountryId);
});
modelBuilder.Entity<DocumentPerson>(entity =>
{
entity.HasIndex(e => e.Name);
entity.HasIndex(e => e.Surname);
entity.HasIndex(e => e.PersonId).IsUnique();
entity.HasOne(d => d.Person).WithOne(p => p.DocumentPerson)
.HasForeignKey<Person>(d => d.DocumentPersonId).OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity<DocumentRole>(entity =>
{
entity.HasIndex(e => e.Name);
@@ -840,6 +853,9 @@ namespace Cicm.Database.Models
entity.HasIndex(e => e.Photo);
entity.HasOne(d => d.CountryOfBirth).WithMany(p => p.People).HasForeignKey(d => d.CountryOfBirthId);
entity.HasOne(d => d.DocumentPerson).WithOne(p => p.Person)
.HasForeignKey<DocumentPerson>(d => d.PersonId).OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity<Processor>(entity =>

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Version>3.0.99.809</Version>
<Version>3.0.99.819</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>