mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Add document company.
This commit is contained in:
7627
Cicm.Database/Migrations/20190616233807_AddDocumentCompany.Designer.cs
generated
Normal file
7627
Cicm.Database/Migrations/20190616233807_AddDocumentCompany.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace Cicm.Database.Migrations
|
||||||
|
{
|
||||||
|
public partial class AddDocumentCompany : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>("DocumentCompanyId", "companies", nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable("DocumentCompanies",
|
||||||
|
table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>()
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy",
|
||||||
|
MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Name = table.Column<string>(),
|
||||||
|
CompanyId = table.Column<int>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_DocumentCompanies", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_companies_DocumentCompanyId", "companies", "DocumentCompanyId",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_DocumentCompanies_CompanyId", "DocumentCompanies", "CompanyId",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex("IX_DocumentCompanies_Name", "DocumentCompanies", "Name");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey("FK_companies_DocumentCompanies_DocumentCompanyId", "companies",
|
||||||
|
"DocumentCompanyId", "DocumentCompanies", principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey("FK_companies_DocumentCompanies_DocumentCompanyId", "companies");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable("DocumentCompanies");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex("IX_companies_DocumentCompanyId", "companies");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn("DocumentCompanyId", "companies");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -107,6 +107,8 @@ namespace Cicm.Database.Migrations
|
|||||||
|
|
||||||
b.Property<short?>("CountryId").HasColumnName("country").HasColumnType("smallint(3)");
|
b.Property<short?>("CountryId").HasColumnName("country").HasColumnType("smallint(3)");
|
||||||
|
|
||||||
|
b.Property<int?>("DocumentCompanyId");
|
||||||
|
|
||||||
b.Property<string>("Facebook").HasColumnName("facebook").HasColumnType("varchar(45)").HasMaxLength(45);
|
b.Property<string>("Facebook").HasColumnName("facebook").HasColumnType("varchar(45)").HasMaxLength(45);
|
||||||
|
|
||||||
b.Property<DateTime?>("Founded").HasColumnName("founded").HasColumnType("datetime");
|
b.Property<DateTime?>("Founded").HasColumnName("founded").HasColumnType("datetime");
|
||||||
@@ -137,6 +139,8 @@ namespace Cicm.Database.Migrations
|
|||||||
|
|
||||||
b.HasIndex("CountryId").HasName("idx_companies_country");
|
b.HasIndex("CountryId").HasName("idx_companies_country");
|
||||||
|
|
||||||
|
b.HasIndex("DocumentCompanyId").IsUnique();
|
||||||
|
|
||||||
b.HasIndex("Facebook").HasName("idx_companies_facebook");
|
b.HasIndex("Facebook").HasName("idx_companies_facebook");
|
||||||
|
|
||||||
b.HasIndex("Founded").HasName("idx_companies_founded");
|
b.HasIndex("Founded").HasName("idx_companies_founded");
|
||||||
@@ -229,6 +233,23 @@ namespace Cicm.Database.Migrations
|
|||||||
b.ToTable("Documents");
|
b.ToTable("Documents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Cicm.Database.Models.DocumentCompany", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id").ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<int?>("CompanyId");
|
||||||
|
|
||||||
|
b.Property<string>("Name").IsRequired();
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CompanyId").IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("Name");
|
||||||
|
|
||||||
|
b.ToTable("DocumentCompanies");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Cicm.Database.Models.DocumentPerson", b =>
|
modelBuilder.Entity("Cicm.Database.Models.DocumentPerson", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id").ValueGeneratedOnAdd();
|
b.Property<int>("Id").ValueGeneratedOnAdd();
|
||||||
@@ -5222,6 +5243,9 @@ namespace Cicm.Database.Migrations
|
|||||||
b.HasOne("Cicm.Database.Models.Iso31661Numeric", "Country").WithMany("Companies")
|
b.HasOne("Cicm.Database.Models.Iso31661Numeric", "Country").WithMany("Companies")
|
||||||
.HasForeignKey("CountryId").HasConstraintName("fk_companies_country");
|
.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")
|
b.HasOne("Cicm.Database.Models.Company", "SoldTo").WithMany("InverseSoldToNavigation")
|
||||||
.HasForeignKey("SoldToId").HasConstraintName("fk_companies_sold_to");
|
.HasForeignKey("SoldToId").HasConstraintName("fk_companies_sold_to");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ namespace Cicm.Database.Models
|
|||||||
public string PostalCode { get; set; }
|
public string PostalCode { get; set; }
|
||||||
public short? CountryId { get; set; }
|
public short? CountryId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public CompanyStatus Status { get; set; }
|
public CompanyStatus Status { get; set; }
|
||||||
|
public int? DocumentCompanyId { get; set; }
|
||||||
|
|
||||||
public virtual Iso31661Numeric Country { get; set; }
|
public virtual Iso31661Numeric Country { get; set; }
|
||||||
[DisplayName("Sold to")]
|
[DisplayName("Sold to")]
|
||||||
@@ -93,6 +94,7 @@ namespace Cicm.Database.Models
|
|||||||
public virtual ICollection<PeopleByCompany> People { get; set; }
|
public virtual ICollection<PeopleByCompany> People { get; set; }
|
||||||
public virtual CompanyLogo LastLogo =>
|
public virtual CompanyLogo LastLogo =>
|
||||||
Logos?.OrderByDescending(l => l.Year).FirstOrDefault();
|
Logos?.OrderByDescending(l => l.Year).FirstOrDefault();
|
||||||
|
public virtual DocumentCompany DocumentCompany { get; set; }
|
||||||
|
|
||||||
[DisplayName("Sold")]
|
[DisplayName("Sold")]
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
|||||||
13
Cicm.Database/Models/DocumentCompany.cs
Normal file
13
Cicm.Database/Models/DocumentCompany.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Cicm.Database.Models
|
||||||
|
{
|
||||||
|
public class DocumentCompany : BaseModel<int>
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int? CompanyId { get; set; }
|
||||||
|
|
||||||
|
public virtual Company Company { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,6 +82,7 @@ namespace Cicm.Database.Models
|
|||||||
public virtual DbSet<DocumentRole> DocumentRoles { get; set; }
|
public virtual DbSet<DocumentRole> DocumentRoles { get; set; }
|
||||||
public virtual DbSet<DocumentPerson> DocumentPeople { get; set; }
|
public virtual DbSet<DocumentPerson> DocumentPeople { get; set; }
|
||||||
public virtual DbSet<PeopleByDocument> PeopleByDocuments { get; set; }
|
public virtual DbSet<PeopleByDocument> PeopleByDocuments { get; set; }
|
||||||
|
public virtual DbSet<DocumentCompany> DocumentCompanies { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
@@ -235,6 +236,9 @@ namespace Cicm.Database.Models
|
|||||||
|
|
||||||
entity.HasOne(d => d.SoldTo).WithMany(p => p.InverseSoldToNavigation).HasForeignKey(d => d.SoldToId)
|
entity.HasOne(d => d.SoldTo).WithMany(p => p.InverseSoldToNavigation).HasForeignKey(d => d.SoldToId)
|
||||||
.HasConstraintName("fk_companies_sold_to");
|
.HasConstraintName("fk_companies_sold_to");
|
||||||
|
|
||||||
|
entity.HasOne(d => d.DocumentCompany).WithOne(p => p.Company)
|
||||||
|
.HasForeignKey<DocumentCompany>(d => d.CompanyId).OnDelete(DeleteBehavior.SetNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity<CompanyDescription>().HasIndex(e => e.Text).ForMySqlIsFullText();
|
modelBuilder.Entity<CompanyDescription>().HasIndex(e => e.Text).ForMySqlIsFullText();
|
||||||
@@ -278,6 +282,16 @@ namespace Cicm.Database.Models
|
|||||||
entity.HasOne(d => d.Country).WithMany(p => p.Documents).HasForeignKey(d => d.CountryId);
|
entity.HasOne(d => d.Country).WithMany(p => p.Documents).HasForeignKey(d => d.CountryId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<DocumentCompany>(entity =>
|
||||||
|
{
|
||||||
|
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 =>
|
modelBuilder.Entity<DocumentPerson>(entity =>
|
||||||
{
|
{
|
||||||
entity.HasIndex(e => e.Name);
|
entity.HasIndex(e => e.Name);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
<Version>3.0.99.820</Version>
|
<Version>3.0.99.821</Version>
|
||||||
<Company>Canary Islands Computer Museum</Company>
|
<Company>Canary Islands Computer Museum</Company>
|
||||||
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
|
||||||
<Product>Canary Islands Computer Museum Website</Product>
|
<Product>Canary Islands Computer Museum Website</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user