mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add people by document.
This commit is contained in:
7597
Cicm.Database/Migrations/20190616233045_AddPeopleByDocument.Designer.cs
generated
Normal file
7597
Cicm.Database/Migrations/20190616233045_AddPeopleByDocument.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Cicm.Database.Migrations
|
||||
{
|
||||
public partial class AddPeopleByDocument : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable("PeopleByDocuments",
|
||||
table => new
|
||||
{
|
||||
Id = table.Column<long>()
|
||||
.Annotation("MySql:ValueGenerationStrategy",
|
||||
MySqlValueGenerationStrategy.IdentityColumn),
|
||||
PersonId = table.Column<int>(),
|
||||
DocumentId = table.Column<long>(),
|
||||
RoleId = table.Column<string>("char(3)")
|
||||
}, constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PeopleByDocuments", x => x.Id);
|
||||
table.ForeignKey("FK_PeopleByDocuments_Documents_DocumentId",
|
||||
x => x.DocumentId, "Documents", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey("FK_PeopleByDocuments_DocumentPeople_PersonId",
|
||||
x => x.PersonId, "DocumentPeople", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey("FK_PeopleByDocuments_DocumentRoles_RoleId",
|
||||
x => x.RoleId, "DocumentRoles", "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex("IX_PeopleByDocuments_DocumentId", "PeopleByDocuments", "DocumentId");
|
||||
|
||||
migrationBuilder.CreateIndex("IX_PeopleByDocuments_PersonId", "PeopleByDocuments", "PersonId");
|
||||
|
||||
migrationBuilder.CreateIndex("IX_PeopleByDocuments_RoleId", "PeopleByDocuments", "RoleId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable("PeopleByDocuments");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4588,6 +4588,27 @@ namespace Cicm.Database.Migrations
|
||||
b.ToTable("PeopleByCompany");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.PeopleByDocument", b =>
|
||||
{
|
||||
b.Property<long>("Id").ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<long>("DocumentId");
|
||||
|
||||
b.Property<int>("PersonId");
|
||||
|
||||
b.Property<string>("RoleId").IsRequired().HasColumnType("char(3)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DocumentId");
|
||||
|
||||
b.HasIndex("PersonId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("PeopleByDocuments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.Person", b =>
|
||||
{
|
||||
b.Property<int>("Id").ValueGeneratedOnAdd();
|
||||
@@ -5343,6 +5364,18 @@ namespace Cicm.Database.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.PeopleByDocument", b =>
|
||||
{
|
||||
b.HasOne("Cicm.Database.Models.Document", "Document").WithMany("People").HasForeignKey("DocumentId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("Cicm.Database.Models.DocumentPerson", "Person").WithMany("Documents")
|
||||
.HasForeignKey("PersonId").OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("Cicm.Database.Models.DocumentRole", "Role").WithMany().HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Cicm.Database.Models.Person",
|
||||
b =>
|
||||
{
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
public class Document : DocumentBase
|
||||
{
|
||||
public virtual Iso31661Numeric Country { get; set; }
|
||||
|
||||
public virtual ICollection<PeopleByDocument> People { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@@ -11,7 +12,8 @@ namespace Cicm.Database.Models
|
||||
public string Surname { get; set; }
|
||||
public int? PersonId { get; set; }
|
||||
|
||||
public virtual Person Person { get; set; }
|
||||
public virtual Person Person { get; set; }
|
||||
public virtual ICollection<PeopleByDocument> Documents { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string FullName => $"{Name} {Surname}";
|
||||
|
||||
18
Cicm.Database/Models/PeopleByDocument.cs
Normal file
18
Cicm.Database/Models/PeopleByDocument.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Cicm.Database.Models
|
||||
{
|
||||
public class PeopleByDocument : BaseModel<long>
|
||||
{
|
||||
public int PersonId { get; set; }
|
||||
public long DocumentId { get; set; }
|
||||
[Column(TypeName = "char(3)")]
|
||||
[Required]
|
||||
public string RoleId { get; set; }
|
||||
|
||||
public virtual DocumentPerson Person { get; set; }
|
||||
public virtual Document Document { get; set; }
|
||||
public virtual DocumentRole Role { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,7 @@ namespace Cicm.Database.Models
|
||||
public virtual DbSet<Document> Documents { get; set; }
|
||||
public virtual DbSet<DocumentRole> DocumentRoles { get; set; }
|
||||
public virtual DbSet<DocumentPerson> DocumentPeople { get; set; }
|
||||
public virtual DbSet<PeopleByDocument> PeopleByDocuments { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
@@ -832,6 +833,17 @@ namespace Cicm.Database.Models
|
||||
entity.HasOne(d => d.Company).WithMany(p => p.People).HasForeignKey(d => d.CompanyId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<PeopleByDocument>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.PersonId);
|
||||
|
||||
entity.HasIndex(e => e.DocumentId);
|
||||
|
||||
entity.HasOne(d => d.Person).WithMany(p => p.Documents).HasForeignKey(d => d.PersonId);
|
||||
|
||||
entity.HasOne(d => d.Document).WithMany(p => p.People).HasForeignKey(d => d.DocumentId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Person>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.Name);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<Version>3.0.99.819</Version>
|
||||
<Version>3.0.99.820</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