Merge branch 'master' into database_fixes

This commit is contained in:
2020-02-09 21:44:52 +00:00
committed by GitHub
38 changed files with 25757 additions and 261 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class FixDocumentCompanyOneToOne : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey("FK_companies_DocumentCompanies_DocumentCompanyId", "companies");
migrationBuilder.DropIndex("IX_companies_DocumentCompanyId", "companies");
migrationBuilder.AlterColumn<int>("CompanyId", "DocumentCompanies", nullable: true, oldClrType: typeof(int),
oldNullable: true);
migrationBuilder.AddForeignKey("FK_DocumentCompanies_companies_CompanyId", "DocumentCompanies", "CompanyId",
"companies", principalColumn: "id", onDelete: ReferentialAction.SetNull);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey("FK_DocumentCompanies_companies_CompanyId", "DocumentCompanies");
migrationBuilder.AlterColumn<int>("CompanyId", "DocumentCompanies", nullable: true, oldClrType: typeof(int),
oldNullable: true);
migrationBuilder.CreateIndex("IX_companies_DocumentCompanyId", "companies", "DocumentCompanyId",
unique: true);
migrationBuilder.AddForeignKey("FK_companies_DocumentCompanies_DocumentCompanyId", "companies",
"DocumentCompanyId", "DocumentCompanies", principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class AddDisplayNameAndAliasToPerson : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>("Alias", "People", nullable: true);
migrationBuilder.AddColumn<string>("DisplayName", "People", nullable: true);
migrationBuilder.CreateIndex("IX_People_Alias", "People", "Alias");
migrationBuilder.CreateIndex("IX_People_DisplayName", "People", "DisplayName");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex("IX_People_Alias", "People");
migrationBuilder.DropIndex("IX_People_DisplayName", "People");
migrationBuilder.DropColumn("Alias", "People");
migrationBuilder.DropColumn("DisplayName", "People");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class AddDisplayNameAndAliasToDocumentPerson : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>("Alias", "DocumentPeople", nullable: true);
migrationBuilder.AddColumn<string>("DisplayName", "DocumentPeople", nullable: true);
migrationBuilder.CreateIndex("IX_DocumentPeople_Alias", "DocumentPeople", "Alias");
migrationBuilder.CreateIndex("IX_DocumentPeople_DisplayName", "DocumentPeople", "DisplayName");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex("IX_DocumentPeople_Alias", "DocumentPeople");
migrationBuilder.DropIndex("IX_DocumentPeople_DisplayName", "DocumentPeople");
migrationBuilder.DropColumn("Alias", "DocumentPeople");
migrationBuilder.DropColumn("DisplayName", "DocumentPeople");
}
}
}

View File

@@ -285,8 +285,6 @@ namespace Cicm.Database.Migrations
b.HasIndex("CountryId").HasName("idx_companies_country");
b.HasIndex("DocumentCompanyId").IsUnique();
b.HasIndex("Facebook").HasName("idx_companies_facebook");
b.HasIndex("Founded").HasName("idx_companies_founded");
@@ -400,6 +398,10 @@ namespace Cicm.Database.Migrations
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<string>("Alias");
b.Property<string>("DisplayName");
b.Property<string>("Name").IsRequired();
b.Property<int?>("PersonId");
@@ -408,6 +410,10 @@ namespace Cicm.Database.Migrations
b.HasKey("Id");
b.HasIndex("Alias");
b.HasIndex("DisplayName");
b.HasIndex("Name");
b.HasIndex("PersonId").IsUnique();
@@ -4960,12 +4966,16 @@ namespace Cicm.Database.Migrations
{
b.Property<int>("Id").ValueGeneratedOnAdd();
b.Property<string>("Alias");
b.Property<DateTime>("BirthDate");
b.Property<short?>("CountryOfBirthId");
b.Property<DateTime?>("DeathDate");
b.Property<string>("DisplayName");
b.Property<int?>("DocumentPersonId");
b.Property<string>("Facebook");
@@ -4982,12 +4992,16 @@ namespace Cicm.Database.Migrations
b.HasKey("Id");
b.HasIndex("Alias");
b.HasIndex("BirthDate");
b.HasIndex("CountryOfBirthId");
b.HasIndex("DeathDate");
b.HasIndex("DisplayName");
b.HasIndex("Facebook");
b.HasIndex("Name");
@@ -5634,9 +5648,6 @@ namespace Cicm.Database.Migrations
b.HasOne("Cicm.Database.Models.Iso31661Numeric", "Country").WithMany("Companies")
.HasForeignKey("CountryId").HasConstraintName("fk_companies_country");
b.HasOne("Cicm.Database.Models.DocumentCompany", "DocumentCompany").WithOne("Company")
.HasForeignKey("Cicm.Database.Models.Company", "DocumentCompanyId").OnDelete(DeleteBehavior.SetNull);
b.HasOne("Cicm.Database.Models.Company", "SoldTo").WithMany("InverseSoldToNavigation")
.HasForeignKey("SoldToId").HasConstraintName("fk_companies_sold_to");
});
@@ -5662,6 +5673,14 @@ namespace Cicm.Database.Migrations
.HasForeignKey("CountryId");
});
modelBuilder.Entity("Cicm.Database.Models.DocumentCompany",
b =>
{
b.HasOne("Cicm.Database.Models.Company", "Company").WithOne("DocumentCompany")
.HasForeignKey("Cicm.Database.Models.DocumentCompany", "CompanyId")
.OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity("Cicm.Database.Models.DocumentPerson",
b =>
{

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
namespace Cicm.Database.Models
@@ -9,7 +10,8 @@ namespace Cicm.Database.Models
public string Name { get; set; }
public int? CompanyId { get; set; }
public virtual Company Company { get; set; }
[DisplayName("Linked company")]
public virtual Company Company { get; set; }
public virtual ICollection<CompaniesByDocument> Documents { get; set; }
public virtual ICollection<CompaniesByBook> Books { get; set; }
public virtual ICollection<CompaniesByMagazine> Magazines { get; set; }

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -9,15 +10,20 @@ namespace Cicm.Database.Models
[Required]
public string Name { get; set; }
[Required]
public string Surname { get; set; }
public int? PersonId { get; set; }
public string Surname { get; set; }
public int? PersonId { get; set; }
public string Alias { get; set; }
[DisplayName("Name to be displayed")]
public string DisplayName { get; set; }
public virtual Person Person { get; set; }
[NotMapped]
[DisplayName("Name")]
public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}";
[DisplayName("Linked person")]
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,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.AspNetCore.Mvc;
namespace Cicm.Database.Models
{
@@ -10,18 +12,29 @@ 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 int? DocumentPersonId { get; set; }
public string Surname { get; set; }
[DisplayName("Country of birth")]
public virtual Iso31661Numeric CountryOfBirth { get; set; }
[DisplayName("Birth date")]
[DataType(DataType.Date)]
public DateTime BirthDate { get; set; }
[DisplayName("Date of death")]
[DataType(DataType.Date)]
public DateTime? DeathDate { get; set; }
[Url]
public string Webpage { get; set; }
[Remote("VerifyTwitter", "People", "Admin")]
public string Twitter { get; set; }
public string Facebook { get; set; }
public Guid Photo { get; set; }
public int? DocumentPersonId { get; set; }
public string Alias { get; set; }
[DisplayName("Name to be displayed")]
public string DisplayName { get; set; }
[NotMapped]
public string FullName => $"{Name} {Surname}";
[DisplayName("Name")]
public string FullName => DisplayName ?? Alias ?? $"{Name} {Surname}";
public short? CountryOfBirthId { get; set; }
public virtual ICollection<PeopleByCompany> Companies { get; set; }

View File

@@ -388,9 +388,6 @@ namespace Cicm.Database.Models
entity.HasIndex(e => e.Name);
entity.HasIndex(e => e.CompanyId).IsUnique();
entity.HasOne(d => d.Company).WithOne(p => p.DocumentCompany)
.HasForeignKey<Company>(d => d.DocumentCompanyId).OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity<DocumentPerson>(entity =>
@@ -401,6 +398,10 @@ namespace Cicm.Database.Models
entity.HasIndex(e => e.PersonId).IsUnique();
entity.HasIndex(e => e.Alias);
entity.HasIndex(e => e.DisplayName);
entity.HasOne(d => d.Person).WithOne(p => p.DocumentPerson)
.HasForeignKey<Person>(d => d.DocumentPersonId).OnDelete(DeleteBehavior.SetNull);
});
@@ -1079,6 +1080,10 @@ namespace Cicm.Database.Models
entity.HasIndex(e => e.Photo);
entity.HasIndex(e => e.Alias);
entity.HasIndex(e => e.DisplayName);
entity.HasOne(d => d.CountryOfBirth).WithMany(p => p.People).HasForeignKey(d => d.CountryOfBirthId);
entity.HasOne(d => d.DocumentPerson).WithOne(p => p.Person)