mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add person model.
This commit is contained in:
5736
Cicm.Database/Migrations/20190602021943_AddPerson.Designer.cs
generated
Normal file
5736
Cicm.Database/Migrations/20190602021943_AddPerson.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
58
Cicm.Database/Migrations/20190602021943_AddPerson.cs
Normal file
58
Cicm.Database/Migrations/20190602021943_AddPerson.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
26
Cicm.Database/Models/Person.cs
Normal file
26
Cicm.Database/Models/Person.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user