Add person model.

This commit is contained in:
2019-06-02 03:29:43 +01:00
parent b4045475ee
commit 4ff9016e41
7 changed files with 5898 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class AddPerson : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("People",
table => new
{
Id = table.Column<int>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(),
Surname = table.Column<string>(),
BirthDate = table.Column<DateTime>(),
DeathDate = table.Column<DateTime>(nullable: true),
Webpage = table.Column<string>(nullable: true),
Twitter = table.Column<string>(nullable: true),
Facebook = table.Column<string>(nullable: true),
Photo = table.Column<Guid>(),
CountryOfBirthId = table.Column<short>(nullable: true)
}, constraints: table =>
{
table.PrimaryKey("PK_People", x => x.Id);
table.ForeignKey("FK_People_iso3166_1_numeric_CountryOfBirthId",
x => x.CountryOfBirthId, "iso3166_1_numeric", "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex("IX_People_BirthDate", "People", "BirthDate");
migrationBuilder.CreateIndex("IX_People_CountryOfBirthId", "People", "CountryOfBirthId");
migrationBuilder.CreateIndex("IX_People_DeathDate", "People", "DeathDate");
migrationBuilder.CreateIndex("IX_People_Facebook", "People", "Facebook");
migrationBuilder.CreateIndex("IX_People_Name", "People", "Name");
migrationBuilder.CreateIndex("IX_People_Photo", "People", "Photo");
migrationBuilder.CreateIndex("IX_People_Surname", "People", "Surname");
migrationBuilder.CreateIndex("IX_People_Twitter", "People", "Twitter");
migrationBuilder.CreateIndex("IX_People_Webpage", "People", "Webpage");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("People");
}
}
}

View File

@@ -4180,6 +4180,51 @@ namespace Cicm.Database.Migrations
b.ToTable("OwnedMachinePhotos");
});
modelBuilder.Entity("Cicm.Database.Models.Person", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<DateTime>("BirthDate");
b.Property<short?>("CountryOfBirthId");
b.Property<DateTime?>("DeathDate");
b.Property<string>("Facebook");
b.Property<string>("Name").IsRequired();
b.Property<Guid>("Photo");
b.Property<string>("Surname").IsRequired();
b.Property<string>("Twitter");
b.Property<string>("Webpage");
b.HasKey("Id");
b.HasIndex("BirthDate");
b.HasIndex("CountryOfBirthId");
b.HasIndex("DeathDate");
b.HasIndex("Facebook");
b.HasIndex("Name");
b.HasIndex("Photo");
b.HasIndex("Surname");
b.HasIndex("Twitter");
b.HasIndex("Webpage");
b.ToTable("People");
});
modelBuilder.Entity("Cicm.Database.Models.Processor", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd().HasColumnName("id").HasColumnType("int(11)");
@@ -4864,6 +4909,13 @@ namespace Cicm.Database.Migrations
.HasForeignKey("UserId").OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Cicm.Database.Models.Person",
b =>
{
b.HasOne("Cicm.Database.Models.Iso31661Numeric", "CountryOfBirth")
.WithMany("People").HasForeignKey("CountryOfBirthId");
});
modelBuilder.Entity("Cicm.Database.Models.Processor", b =>
{
b.HasOne("Cicm.Database.Models.Company", "Company").WithMany("Processors").HasForeignKey("CompanyId")

View File

@@ -47,5 +47,6 @@ namespace Cicm.Database.Models
public string Name { get; set; }
public virtual ICollection<Company> Companies { get; set; }
public virtual ICollection<Person> People { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Cicm.Database.Models
{
public class Person : BaseModel<int>
{
[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; }
[NotMapped]
public string FullName => $"{Name} {Surname}";
public short? CountryOfBirthId { get; set; }
}
}

View File

@@ -76,6 +76,7 @@ namespace Cicm.Database.Models
public virtual DbSet<Screen> Screens { get; set; }
public virtual DbSet<ScreensByMachine> ScreensByMachine { get; set; }
public virtual DbSet<ResolutionsByScreen> ResolutionsByScreen { get; set; }
public virtual DbSet<Person> People { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -751,6 +752,29 @@ namespace Cicm.Database.Models
entity.Property(e => e.Type).HasColumnName("type").HasColumnType("int(11)").HasDefaultValueSql("'0'");
});
modelBuilder.Entity<Person>(entity =>
{
entity.HasIndex(e => e.Name);
entity.HasIndex(e => e.Surname);
entity.HasIndex(e => e.CountryOfBirthId);
entity.HasIndex(e => e.BirthDate);
entity.HasIndex(e => e.DeathDate);
entity.HasIndex(e => e.Webpage);
entity.HasIndex(e => e.Twitter);
entity.HasIndex(e => e.Facebook);
entity.HasIndex(e => e.Photo);
entity.HasOne(d => d.CountryOfBirth).WithMany(p => p.People).HasForeignKey(d => d.CountryOfBirthId);
});
modelBuilder.Entity<Processor>(entity =>
{
entity.ToTable("processors");

View File

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