Add people by magazine.

This commit is contained in:
2019-06-17 04:10:14 +01:00
parent e4edf83afc
commit e76e09112d
8 changed files with 8237 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,45 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class AddPeopleByMagazine : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable("PeopleByMagazines",
table => new
{
Id = table.Column<long>()
.Annotation("MySql:ValueGenerationStrategy",
MySqlValueGenerationStrategy.IdentityColumn),
PersonId = table.Column<int>(),
MagazineId = table.Column<long>(),
RoleId = table.Column<string>("char(3)")
}, constraints: table =>
{
table.PrimaryKey("PK_PeopleByMagazines", x => x.Id);
table.ForeignKey("FK_PeopleByMagazines_MagazineIssues_MagazineId",
x => x.MagazineId, "MagazineIssues", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByMagazines_DocumentPeople_PersonId",
x => x.PersonId, "DocumentPeople", "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey("FK_PeopleByMagazines_DocumentRoles_RoleId",
x => x.RoleId, "DocumentRoles", "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex("IX_PeopleByMagazines_MagazineId", "PeopleByMagazines", "MagazineId");
migrationBuilder.CreateIndex("IX_PeopleByMagazines_PersonId", "PeopleByMagazines", "PersonId");
migrationBuilder.CreateIndex("IX_PeopleByMagazines_RoleId", "PeopleByMagazines", "RoleId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable("PeopleByMagazines");
}
}
}

View File

@@ -4901,6 +4901,27 @@ namespace Cicm.Database.Migrations
b.ToTable("PeopleByDocuments");
});
modelBuilder.Entity("Cicm.Database.Models.PeopleByMagazine", b =>
{
b.Property<long>("Id").ValueGeneratedOnAdd();
b.Property<long>("MagazineId");
b.Property<int>("PersonId");
b.Property<string>("RoleId").IsRequired().HasColumnType("char(3)");
b.HasKey("Id");
b.HasIndex("MagazineId");
b.HasIndex("PersonId");
b.HasIndex("RoleId");
b.ToTable("PeopleByMagazines");
});
modelBuilder.Entity("Cicm.Database.Models.Person", b =>
{
b.Property<int>("Id").ValueGeneratedOnAdd();
@@ -5780,6 +5801,18 @@ namespace Cicm.Database.Migrations
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Cicm.Database.Models.PeopleByMagazine", b =>
{
b.HasOne("Cicm.Database.Models.MagazineIssue", "Magazine").WithMany("People")
.HasForeignKey("MagazineId").OnDelete(DeleteBehavior.Cascade);
b.HasOne("Cicm.Database.Models.DocumentPerson", "Person").WithMany("Magazines")
.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 =>
{

View File

@@ -15,6 +15,7 @@ namespace Cicm.Database.Models
public virtual Person Person { get; set; }
public virtual ICollection<PeopleByDocument> Documents { get; set; }
public virtual ICollection<PeopleByBook> Books { get; set; }
public virtual ICollection<PeopleByMagazine> Magazines { get; set; }
[NotMapped]
public string FullName => $"{Name} {Surname}";

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Cicm.Database.Models
@@ -17,6 +18,7 @@ namespace Cicm.Database.Models
public string ProductCode { get; set; }
public short Pages { get; set; }
public virtual Magazine Magazine { get; set; }
public virtual Magazine Magazine { get; set; }
public virtual ICollection<PeopleByMagazine> People { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Cicm.Database.Models
{
public class PeopleByMagazine : BaseModel<long>
{
public int PersonId { get; set; }
public long MagazineId { get; set; }
[Column(TypeName = "char(3)")]
[Required]
public string RoleId { get; set; }
public virtual DocumentPerson Person { get; set; }
public virtual MagazineIssue Magazine { get; set; }
public virtual DocumentRole Role { get; set; }
}
}

View File

@@ -93,6 +93,7 @@ namespace Cicm.Database.Models
public virtual DbSet<Magazine> Magazines { get; set; }
public virtual DbSet<MagazineIssue> MagazineIssues { get; set; }
public virtual DbSet<CompaniesByMagazine> CompaniesByMagazines { get; set; }
public virtual DbSet<PeopleByMagazine> PeopleByMagazines { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@@ -1023,6 +1024,17 @@ namespace Cicm.Database.Models
entity.HasOne(d => d.Document).WithMany(p => p.People).HasForeignKey(d => d.DocumentId);
});
modelBuilder.Entity<PeopleByMagazine>(entity =>
{
entity.HasIndex(e => e.PersonId);
entity.HasIndex(e => e.MagazineId);
entity.HasOne(d => d.Person).WithMany(p => p.Magazines).HasForeignKey(d => d.PersonId);
entity.HasOne(d => d.Magazine).WithMany(p => p.People).HasForeignKey(d => d.MagazineId);
});
modelBuilder.Entity<Person>(entity =>
{
entity.HasIndex(e => e.Name);

View File

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