334 lines
26 KiB
C#
334 lines
26 KiB
C#
using Gremlin_BlazorServer.Data.EntityClasses;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Gremlin_BlazorServer.Data.DBClasses;
|
|
|
|
public class AccountConfiguration : IEntityTypeConfiguration<Account> {
|
|
public void Configure(EntityTypeBuilder<Account> accountEntity) {
|
|
accountEntity.HasKey(e => e.AccountId);
|
|
|
|
accountEntity.HasMany(d => d.Contacts).WithOne(p => p.Account);
|
|
// accountEntity.HasMany(d => d.CustomDescriptions).WithOne(p => p.Supplier);
|
|
accountEntity.HasOne(d => d.AccountType).WithMany(p => p.Accounts).HasForeignKey(fk => fk.AccountTypeCode);
|
|
accountEntity.HasOne(d => d.SubMarket).WithMany(p => p.Accounts).HasForeignKey(fk => fk.SubMarketCode);
|
|
|
|
accountEntity.HasAlternateKey(e => e.SapAccountNumber); // =Unique
|
|
|
|
accountEntity.Property(e => e.AccountId).ValueGeneratedOnAdd();
|
|
// accountEntity.Property(e => e.ParentAccountId).HasDefaultValue(0);
|
|
accountEntity.Property(e => e.AccountName).IsRequired().HasMaxLength(250);
|
|
accountEntity.Property(e => e.Notes).HasDefaultValue("");
|
|
accountEntity.Property(e => e.Street).IsRequired().HasMaxLength(100);
|
|
accountEntity.Property(e => e.Zip).IsRequired().HasColumnType("Char(5)");
|
|
accountEntity.Property(e => e.City).IsRequired().HasMaxLength(50);
|
|
accountEntity.Property(e => e.FloorOrBuilding).HasMaxLength(50);
|
|
accountEntity.Property(e => e.Longitude).HasDefaultValue(0);
|
|
accountEntity.Property(e => e.Latitude).HasDefaultValue(0);
|
|
accountEntity.Property(e => e.PhoneNumber).IsRequired().HasMaxLength(30);
|
|
accountEntity.Property(e => e.FaxNumber).HasMaxLength(30).HasDefaultValue("");
|
|
accountEntity.Property(e => e.Webpage).HasMaxLength(250).HasDefaultValue("");
|
|
accountEntity.Property(e => e.EMail).HasMaxLength(150).HasDefaultValue("");
|
|
accountEntity.Property(e => e.SapAccountNumber).IsRequired();
|
|
accountEntity.Property(e => e.AccountCreatedInSapOn).IsRequired();
|
|
|
|
accountEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
accountEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
accountEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
accountEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
accountEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
|
|
accountEntity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active"); //.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!?
|
|
accountEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(); //.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true)
|
|
accountEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class ContactConfiguration : IEntityTypeConfiguration<Contact> {
|
|
public void Configure(EntityTypeBuilder<Contact> contactEntity) {
|
|
contactEntity.HasKey(e => e.ContactId);
|
|
|
|
contactEntity.HasOne(p => p.Account).WithMany(d => d.Contacts).HasForeignKey(fk => fk.AccountId);
|
|
// contactEntity.HasMany(q => q.Quotes).WithOne(c => c.Recipient).HasForeignKey(fk => fk.QuoteId);
|
|
|
|
contactEntity.HasAlternateKey(e => e.SapContactNumber);
|
|
|
|
contactEntity.Property(e => e.ContactId);
|
|
contactEntity.Property(e => e.SapContactNumber).IsRequired();
|
|
contactEntity.Property(e => e.AcademicTitle).HasDefaultValue("");
|
|
contactEntity.Property(e => e.FirstName).HasDefaultValue("");
|
|
contactEntity.Property(e => e.LastName).IsRequired();
|
|
contactEntity.Property(e => e.Gender).HasDefaultValue(0);
|
|
//.IsRequired(true) darf nicht gesetzt werden, da sonst vom DB-Engine NULL nicht erlaubt wird (trotz Definition als Bool? im Code. MySQL kennt kein Bool, sondern wandelt das intern in Tinyint um).
|
|
contactEntity.Property(e => e.OptInStatus).HasDefaultValue(false);
|
|
contactEntity.Property(e => e.IsReference).HasDefaultValue(false);
|
|
contactEntity.Property(e => e.Notes).HasDefaultValue("");
|
|
contactEntity.Property(e => e.ValidatedContact).HasDefaultValue(false);
|
|
|
|
contactEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
contactEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
contactEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
contactEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
contactEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
|
|
contactEntity.Property(e => e.DataStatus).IsRequired();
|
|
//.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!?
|
|
contactEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
//.IsRowVersion() impliziert .ValueGeneratedOnAddOrUpdate() und .IsConcurrencyToken(true)
|
|
contactEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class SalesRepConfiguration : IEntityTypeConfiguration<SalesRep> {
|
|
public void Configure(EntityTypeBuilder<SalesRep> salesRepEntity) {
|
|
salesRepEntity.HasKey(e => e.SalesRepId);
|
|
|
|
salesRepEntity.HasOne(p => p.Account).WithMany(d => d.SalesReps).HasForeignKey(fk => fk.AccountId);
|
|
// salesRepEntity.HasMany(q => q.Quotes).WithOne(c => c.SalesRep).HasForeignKey(fk => fk.SalesRepId);
|
|
|
|
salesRepEntity.Property(e => e.SalesRepId);
|
|
salesRepEntity.Property(e => e.AcademicTitle).HasDefaultValue("");
|
|
salesRepEntity.Property(e => e.FirstName).HasDefaultValue("");
|
|
salesRepEntity.Property(e => e.LastName).IsRequired();
|
|
salesRepEntity.Property(e => e.Gender).HasDefaultValue(0);
|
|
|
|
salesRepEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
salesRepEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
salesRepEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
salesRepEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
salesRepEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
|
|
salesRepEntity.Property(e => e.DataStatus).IsRequired();
|
|
salesRepEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
salesRepEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class QuoteConfiguration : IEntityTypeConfiguration<Quote> {
|
|
public void Configure(EntityTypeBuilder<Quote> quoteEntity) {
|
|
quoteEntity.HasKey(e => e.QuoteId);
|
|
|
|
// quoteEntity.HasOne(e => e.Recipient).WithMany(c => c.Quotes).HasForeignKey(fk => fk.RecipientId);
|
|
// quoteEntity.HasOne(e => e.SalesRep).WithMany(sR => sR.Quotes).HasForeignKey(fk => fk.SalesRepId);
|
|
|
|
// quoteEntity.HasMany(q => q.LineItems).WithOne(lI => lI.Quote).HasForeignKey(fk => fk.QuoteId);
|
|
|
|
quoteEntity.Property(e => e.QuotationNumber).HasColumnType("VARCHAR(255)").ValueGeneratedOnAdd();
|
|
quoteEntity.Property(e => e.QuotationDate).ValueGeneratedOnAdd();
|
|
quoteEntity.Property(e => e.ValidUntil);
|
|
quoteEntity.Property(e => e.ValidFor);
|
|
quoteEntity.Property(e => e.TotalListprice);
|
|
quoteEntity.Property(e => e.TotalDiscount);
|
|
quoteEntity.Property(e => e.TotalNet);
|
|
quoteEntity.Property(e => e.Vat);
|
|
quoteEntity.Property(e => e.TotalGross);
|
|
quoteEntity.Property(e => e.QuoteContains3Pp).HasDefaultValue(false);
|
|
quoteEntity.Property(e => e.QuoteContainsRb).HasDefaultValue(false);
|
|
quoteEntity.Property(e => e.QuoteTemplate).HasDefaultValue("");
|
|
|
|
quoteEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
quoteEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
quoteEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
quoteEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
quoteEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
|
|
quoteEntity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active");
|
|
quoteEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
quoteEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class LineItemConfiguration : IEntityTypeConfiguration<LineItem> {
|
|
public void Configure(EntityTypeBuilder<LineItem> lineItemEntity) {
|
|
lineItemEntity.HasKey(e => e.LineItemId);
|
|
|
|
// lineItemEntity.HasOne(p => p.Quote).WithMany(d => d.LineItems).HasForeignKey(fk => fk.QuoteId);
|
|
// lineItemEntity.HasOne(lI => lI.CustomDescription).WithMany(d => d.LineItems).HasForeignKey(fk => fk.CustomDescriptionId);
|
|
// lineItemEntity.HasOne(lI => lI.Product).WithMany(p => p.LineItems).HasForeignKey(fK => fK.LineItemId);
|
|
|
|
lineItemEntity.Property(e => e.Position).IsRequired();
|
|
lineItemEntity.Property(e => e.Amount).IsRequired();
|
|
lineItemEntity.Property(e => e.ProductNumber).IsRequired();
|
|
lineItemEntity.Property(e => e.OptionNumber).HasDefaultValue("");
|
|
lineItemEntity.Property(e => e.SapShortDescription).HasDefaultValue("");
|
|
lineItemEntity.Property(e => e.SapLongDescription).HasDefaultValue("");
|
|
lineItemEntity.Property(e => e.ProductLine).HasDefaultValue("");
|
|
lineItemEntity.Property(e => e.TotalDiscount).IsRequired().HasDefaultValue(0);
|
|
lineItemEntity.Property(e => e.SalesDiscount).IsRequired().HasDefaultValue(0);
|
|
lineItemEntity.Property(e => e.PromotionalDiscount).IsRequired().HasDefaultValue(0);
|
|
lineItemEntity.Property(e => e.ContractualDiscount).IsRequired().HasDefaultValue(0);
|
|
lineItemEntity.Property(e => e.DemoDiscount).IsRequired().HasDefaultValue(0);
|
|
lineItemEntity.Property(e => e.ListPrice).IsRequired();
|
|
lineItemEntity.Property(e => e.ExtendedListPrice).IsRequired();
|
|
lineItemEntity.Property(e => e.NetPrice).IsRequired();
|
|
lineItemEntity.Property(e => e.Total).IsRequired();
|
|
|
|
lineItemEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
lineItemEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
lineItemEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
lineItemEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
lineItemEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
|
|
lineItemEntity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active");
|
|
lineItemEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
lineItemEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class ProductConfiguration : IEntityTypeConfiguration<Product> {
|
|
public void Configure(EntityTypeBuilder<Product> productEntity) {
|
|
productEntity.HasKey(e => e.ProductId);
|
|
|
|
productEntity.HasOne(p => p.ProductLine).WithMany(d => d.Products).HasForeignKey(fk => fk.ProductLineCode).OnDelete(DeleteBehavior.Restrict);
|
|
// productEntity.HasOne(p => p.CustomDescription).WithOne(cD => cD.Product).HasForeignKey<CustomDescription>(cD => cD.ProductId);
|
|
|
|
// productEntity.HasMany(p => p.LineItems).WithOne(lI => lI.Product).HasForeignKey(fK => fK.ProductId);
|
|
|
|
productEntity.Property(p => p.ProductNumber).IsRequired();
|
|
productEntity.Property(p => p.OptionNumber).HasDefaultValue("");
|
|
productEntity.Property(p => p.SapShortDescription).HasDefaultValue("");
|
|
productEntity.Property(p => p.SapLongDescription).HasDefaultValue("");
|
|
productEntity.Property(p => p.Weight);
|
|
productEntity.Property(p => p.ProductStatus).HasDefaultValue("Active");
|
|
productEntity.Property(p => p.IntroductionDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
productEntity.Property(p => p.ListPrice);
|
|
productEntity.Property(p => p.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
productEntity.Property(p => p.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
productEntity.Property(p => p.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
productEntity.Property(p => p.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
productEntity.Property(p => p.DataVersionComment).HasDefaultValue("Gremlin_BlazorServer");
|
|
productEntity.Property(p => p.DataStatus).IsRequired().HasDefaultValue("Active");
|
|
productEntity.Property(p => p.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
productEntity.Property(p => p.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class CustomDescriptionConfiguration : IEntityTypeConfiguration<CustomDescription> {
|
|
public void Configure(EntityTypeBuilder<CustomDescription> customDescriptionEntity) {
|
|
customDescriptionEntity.HasKey(cD => cD.CustomDescriptionId);
|
|
// customDescriptionEntity.HasOne(cD => cD.Product).WithOne(p => p.CustomDescription).HasForeignKey(fk => fk.ProductLineCode);
|
|
// customDescriptionEntity.HasOne(p => p.Supplier).WithMany(d => d.CustomDescriptions).IsRequired();
|
|
|
|
customDescriptionEntity.Property(e => e.ProductNumber).IsRequired();
|
|
customDescriptionEntity.Property(e => e.OptionNumber).HasDefaultValue("");
|
|
customDescriptionEntity.Property(e => e.Heading).IsRequired();
|
|
customDescriptionEntity.Property(e => e.DescriptionText).HasDefaultValue("");
|
|
customDescriptionEntity.Property(e => e.CoverletterText).HasDefaultValue("");
|
|
customDescriptionEntity.Property(e => e.Notes).HasDefaultValue("");
|
|
|
|
customDescriptionEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
customDescriptionEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
customDescriptionEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
customDescriptionEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
customDescriptionEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
|
|
customDescriptionEntity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active");
|
|
customDescriptionEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
customDescriptionEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class ProductLineConfiguration : IEntityTypeConfiguration<ProductLine> {
|
|
public void Configure(EntityTypeBuilder<ProductLine> productLineEntity) {
|
|
productLineEntity.HasMany(p => p.Products).WithOne(d => d.ProductLine).IsRequired().OnDelete(DeleteBehavior.Restrict);
|
|
|
|
productLineEntity.Property(e => e.ProductLineDescription).IsRequired();
|
|
|
|
productLineEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
productLineEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
productLineEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
productLineEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
productLineEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
|
|
productLineEntity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active");
|
|
productLineEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
productLineEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class AccountTypeConfiguration : IEntityTypeConfiguration<AccountType> {
|
|
public void Configure(EntityTypeBuilder<AccountType> accountTypeEntity) {
|
|
accountTypeEntity.HasKey(e => e.AccountTypeCode);
|
|
accountTypeEntity.HasMany(p => p.Accounts).WithOne(d => d.AccountType); //already defined in class Account
|
|
accountTypeEntity.Property(e => e.AccountTypeCode).IsRequired().HasColumnType("Char(3)");
|
|
accountTypeEntity.Property(e => e.AccountTypeDescription).HasColumnType("Varchar(1000)").IsRequired();
|
|
|
|
accountTypeEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
accountTypeEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
accountTypeEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
accountTypeEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
accountTypeEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
|
|
accountTypeEntity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active");
|
|
accountTypeEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
accountTypeEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class SubMarketConfiguration : IEntityTypeConfiguration<SubMarket> {
|
|
public void Configure(EntityTypeBuilder<SubMarket> subMarketEntity) {
|
|
subMarketEntity.HasKey(e => e.SubMarketCode);
|
|
subMarketEntity.HasMany(p => p.Accounts).WithOne(d => d.SubMarket); //already defined in class Account
|
|
subMarketEntity.Property(e => e.SubMarketCode).HasColumnType("Char(3)");
|
|
subMarketEntity.Property(e => e.SubMarketDescription).HasColumnType("Varchar(1000)").IsRequired();
|
|
|
|
subMarketEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
subMarketEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
subMarketEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
subMarketEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
subMarketEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
|
|
subMarketEntity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active");
|
|
subMarketEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
subMarketEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class RegisteredUserConfiguration : IEntityTypeConfiguration<RegisteredUser> {
|
|
public void Configure(EntityTypeBuilder<RegisteredUser> registeredUserEntity) {
|
|
registeredUserEntity.HasKey(e => e.RegisteredUserId);
|
|
|
|
registeredUserEntity.HasMany(d => d.RuSettings).WithOne(p => p.RegisteredUser).IsRequired();
|
|
registeredUserEntity.Property(e => e.UserName).IsRequired();
|
|
registeredUserEntity.Property(e => e.PasswordHash).IsRequired();
|
|
|
|
registeredUserEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
registeredUserEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
registeredUserEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class RuSettingsConfiguration : IEntityTypeConfiguration<RuSettings> {
|
|
public void Configure(EntityTypeBuilder<RuSettings> rUSettingsEntitity) {
|
|
rUSettingsEntitity.HasKey(e => e.RuSettingsId);
|
|
|
|
rUSettingsEntitity.HasOne(d => d.RegisteredUser).WithMany(p => p.RuSettings).IsRequired();
|
|
rUSettingsEntitity.Property(e => e.SettingKey).IsRequired();
|
|
rUSettingsEntitity.Property(e => e.SettingValue).IsRequired();
|
|
|
|
rUSettingsEntitity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
rUSettingsEntitity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
rUSettingsEntitity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
}
|
|
|
|
public class OpportunityConfiguration : IEntityTypeConfiguration<Opportunity> {
|
|
public void Configure(EntityTypeBuilder<Opportunity> opportunityEntity) {
|
|
opportunityEntity.HasKey(e => e.OpportunityId);
|
|
|
|
opportunityEntity.Property(e => e.AccountName);
|
|
opportunityEntity.Property(e => e.ContactName);
|
|
opportunityEntity.Property(e => e.OppProductLineCode);
|
|
opportunityEntity.Property(e => e.MainCompetitorName);
|
|
opportunityEntity.Property(e => e.Description);
|
|
opportunityEntity.Property(e => e.ForecastDate);
|
|
opportunityEntity.Property(e => e.FollowUpDate);
|
|
opportunityEntity.Property(e => e.ExpSalesVolume);
|
|
opportunityEntity.Property(e => e.WinProbability);
|
|
opportunityEntity.Property(e => e.Notes);
|
|
opportunityEntity.Property(e => e.PrimaryCampaignId);
|
|
opportunityEntity.Property(e => e.SecondaryCampaignId);
|
|
opportunityEntity.Property(e => e.SapOpportunityNumber);
|
|
opportunityEntity.Property(e => e.OpportunityStartDate);
|
|
|
|
opportunityEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
opportunityEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
|
|
opportunityEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
|
|
opportunityEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
|
|
opportunityEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
|
|
opportunityEntity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active");
|
|
opportunityEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
|
|
opportunityEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
|
|
}
|
|
} |