Fixes to model:

- added relationship contact-quote (0,1:n).
- changed relationship CD - product to 0,1:n.
- removed FK 'ProductId' from CD (no longer required due to relationsship change).
- removed property 'LinkToSap' from contact model.
- fixed LineItem PK (was 'QuoteId').
- fixed LineItem - quote relationsship.
- specified FK in some relationships to avoid duplicate fields generated by wrong EF Core guesses.
- set all PKs to Uint.
- Moved FKs in Quote.cs up.
- RegisteredUser.cs and RUSettings.cs: moved metadata down.
pull/1/head
Basimodo 2021-06-28 10:10:57 +07:00
parent 94a49498fb
commit cc6089f65a
10 changed files with 23 additions and 25 deletions

@ -79,8 +79,6 @@ namespace Gremlin.GremlinData.DBClasses
/// Initialzes the Db with enum data: product lines, account types, submarkets
{
DateTime now = DateTime.Now;
//PRODUCT LINES
string[] ProductLineAbbrviations = { "XF", "LM", "XA", "RB", "GE",
"9Z", "9P", "9M", "9K", "9H",
@ -1051,6 +1049,8 @@ namespace Gremlin.GremlinData.DBClasses
{
// Read current line fields, pointer moves to the next line.
string[] fields = csvParser.ReadFields();
//string productNumber = fields[0];
//string? optionNumber = fields[1] == "" ? null : fields[1];
CustomDescription ImportedCD = new()
{
ProductNumber = fields[0],

@ -64,7 +64,6 @@ namespace Gremlin.GremlinData.DBClasses
entity.Property(e => e.OptInStatus).HasDefaultValue(null);
entity.Property(e => e.IsReference).HasDefaultValue(false);
entity.Property(e => e.Notes);
entity.Property(e => e.LinkToSAP);
entity.Property(e => e.ValidatedContact).HasDefaultValue(false);
entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
@ -121,8 +120,8 @@ namespace Gremlin.GremlinData.DBClasses
{
public void Configure(EntityTypeBuilder<LineItem> entity)
{
entity.HasKey(e => e.QuoteId);
entity.HasOne(p => p.Quote).WithMany(d => d.LineItems).HasForeignKey(fk => fk.QuoteId);
entity.HasKey(e => e.LineItemId);
entity.HasOne(p => p.Quote).WithMany(d => d.LineItems).HasForeignKey(fk => fk.QuoteId).IsRequired(true).OnDelete(DeleteBehavior.Cascade);
entity.Property(e => e.Position).IsRequired(true);
entity.Property(e => e.Amount).IsRequired(true);
@ -159,8 +158,8 @@ namespace Gremlin.GremlinData.DBClasses
public void Configure(EntityTypeBuilder<Product> entity)
{
entity.HasKey(e => e.ProductId);
entity.HasOne(d => d.CustomDescription).WithMany(p => p.Products).IsRequired(false).OnDelete(DeleteBehavior.Restrict);
entity.HasOne(p => p.ProductLine).WithMany(d => d.Products).IsRequired(true).OnDelete(DeleteBehavior.Restrict);
entity.HasOne(d => d.CustomDescription).WithMany(p => p.Products).HasForeignKey("CustomDescriptionId").IsRequired(false).OnDelete(DeleteBehavior.Restrict);
entity.HasOne(p => p.ProductLine).WithMany(d => d.Products).HasForeignKey("ProductLineCode").IsRequired(true).OnDelete(DeleteBehavior.Restrict);
entity.Property(e => e.ProductNumber).IsRequired(true);
entity.Property(e => e.OptionNumber);

@ -321,7 +321,7 @@ namespace Gremlin.GremlinData.DBClasses
DataValidUntil = FarInTheFuture,
DataVersionComment = "Initial Importer by CD-ImporterFomCsv",
};
ImportedCD.Products = new();
ImportedCD.Products = new List<Product>();
ImportedCD.Supplier = new();
ImportedCD.Supplier.AccountName = fields[2] is "" or "RB" ? "Agilent Technologies" : fields[2];
ImportedCD.DataCreationDate = ImportedCD.DataValidFrom = ImportedCD.DataModificationDate = DateTime.Now;

@ -11,7 +11,7 @@ namespace Gremlin.GremlinData.EntityClasses
//foreign keys:
public IList<Contact> Contacts { get; set; }
public int? ParentAccountId { get; set; }
public uint? ParentAccountId { get; set; }
public AccountType AccountType { get; set; }
public SubMarket SubMarket { get; set; }
public IList<CustomDescription> CustomDescriptions { get; set; }

@ -44,8 +44,7 @@ namespace Gremlin.GremlinData.EntityClasses
public string SAPApplicationInterest { get; set; }
public string SAPJobLevel { get; set; }
public string SAPCompetitiveIBase { get; set; }
public string LinkToSAP { get; set; }
//metadata:
public DateTime DataCreationDate { get; set; }
public DateTime DataModificationDate { get; set; }

@ -9,7 +9,7 @@ namespace Gremlin.GremlinData.EntityClasses
public uint CustomDescriptionId { get; set; }
//foreign keys:
public uint ProductId { get; set; }
//public uint ProductId { get; set; }
public uint AccountId { get; set; }
//navigation properties:

@ -12,7 +12,7 @@ namespace Gremlin.GremlinData.EntityClasses
public ProductLine ProductLine { get; set; }
//foreign keys
public int CustomDescriptionId { get; set; }
public uint CustomDescriptionId { get; set; }
public string ProductLineCode { get; set; }
//Agilent-specific properties:

@ -9,18 +9,18 @@ namespace Gremlin.GremlinData.EntityClasses
public uint QuoteId { get; set; }
//foreign keys:
public Contact Recipient { get; set; }
public IList<LineItem> LineItems { get; set; }
//navigation properties:
//NONE
//class properties:
public Contact SalesRep { get; set; }
public string QuotationNumber { get; set; }
public DateTime QuotationDate { get; set; }
public DateTime ValidUntil { get; set; }
public byte ValidFor { get; set; }
public Contact Recipient { get; set; }
public Contact SalesRep { get; set; }
public decimal TotalListprice { get; set; }
public decimal TotalDiscount { get; set; }
public decimal TotalNet { get; set; }

@ -13,15 +13,15 @@ namespace Gremlin.GremlinData.EntityClasses
//navigation properties
public RegisteredUser RegisteredUser { get; set; }
//standard properties:
public DateTime DataCreationDate { get; set; }
public DateTime DataModificationDate { get; set; }
public string DataModificationByUser { get; set; }
//class properties
public string SettingKey { get; set; }
public string SettingValue { get; set; }
//metadata (subset of IMetadata)
public DateTime DataCreationDate { get; set; }
public DateTime DataModificationDate { get; set; }
public string DataModificationByUser { get; set; }
//Constructur
public RUSetting()
{

@ -11,14 +11,14 @@ namespace Gremlin.GremlinData.EntityClasses
//navigation properties
public IList<RUSetting> RUSettings { get; set; }
//standard properties
public DateTime DataCreationDate { get; set; }
public DateTime DataModificationDate { get; set; }
public string DataModificationByUser { get; set; }
//class properties
public string UserName { get; set; }
public string PasswordHash { get; set; }
//metadata (subset of IMetadata)
public DateTime DataCreationDate { get; set; }
public DateTime DataModificationDate { get; set; }
public string DataModificationByUser { get; set; }
//Constructur
public RegisteredUser()