rider code optimization

pull/1/head
Sascha 2023-01-09 00:04:10 +07:00
parent 1eaee032b7
commit 912d56031b
48 changed files with 1507 additions and 1748 deletions

File diff suppressed because it is too large Load Diff

@ -44,7 +44,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
public static string ToInsecureString(SecureString input)
{
string returnValue = string.Empty;
string returnValue;
IntPtr ptr = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(input);
try
{

@ -9,38 +9,38 @@ namespace Gremlin_BlazorServer.Data.DBClasses
public void Configure(EntityTypeBuilder<Account> accountEntity)
{
_ = accountEntity.HasKey(e => e.AccountId);
_ = accountEntity.HasMany(d => d.Contacts).WithOne(p => p.Account).IsRequired(true);
_ = accountEntity.HasOne(d => d.AccountType).WithMany(p => p.Accounts).IsRequired(true).OnDelete(DeleteBehavior.Restrict);
_ = accountEntity.HasOne(d => d.SubMarket).WithMany(p => p.Accounts).IsRequired(true).OnDelete(DeleteBehavior.Restrict);
_ = accountEntity.HasAlternateKey(e => e.SAPAccountNumber); // =Unique
_ = accountEntity.HasMany(d => d.Contacts).WithOne(p => p.Account).IsRequired();
_ = accountEntity.HasOne(d => d.AccountType).WithMany(p => p.Accounts).IsRequired().OnDelete(DeleteBehavior.Restrict);
_ = accountEntity.HasOne(d => d.SubMarket).WithMany(p => p.Accounts).IsRequired().OnDelete(DeleteBehavior.Restrict);
_ = 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(true).HasMaxLength(250);
_ = accountEntity.Property(e => e.AccountName).IsRequired().HasMaxLength(250);
_ = accountEntity.Property(e => e.Notes).HasDefaultValue("");
_ = accountEntity.Property(e => e.Street).IsRequired(true).HasMaxLength(100);
_ = accountEntity.Property(e => e.ZIP).IsRequired(true).HasColumnType("Char(5)");
_ = accountEntity.Property(e => e.City).IsRequired(true).HasMaxLength(50);
_ = 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(true).HasMaxLength(30);
_ = 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(true);
_ = accountEntity.Property(e => e.AccountCreatedInSAPOn).IsRequired(true);
_ = 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(true);
_ = accountEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
_ = accountEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
_ = accountEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
_ = accountEntity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active");
//.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core?
_ = accountEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
_ = 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(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
_ = accountEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
}
}
@ -49,14 +49,14 @@ namespace Gremlin_BlazorServer.Data.DBClasses
public void Configure(EntityTypeBuilder<Contact> contactEntity)
{
_ = contactEntity.HasKey(e => e.ContactId);
_ = contactEntity.HasOne(p => p.Account).WithMany(d => d.Contacts).IsRequired(true);
_ = contactEntity.HasOne(p => p.Account).WithMany(d => d.Contacts).IsRequired();
//entity.HasAlternateKey(e => e.SAPContactNumber);
_ = contactEntity.Property(e => e.ContactId);
_ = contactEntity.Property(e => e.SAPContactNumber).IsRequired(true);
_ = contactEntity.Property(e => e.SapContactNumber).IsRequired();
_ = contactEntity.Property(e => e.AcademicTitle).HasDefaultValue("");
_ = contactEntity.Property(e => e.FirstName).HasDefaultValue("");
_ = contactEntity.Property(e => e.LastName).IsRequired(true);
_ = 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);
@ -67,13 +67,13 @@ namespace Gremlin_BlazorServer.Data.DBClasses
_ = 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(true);
_ = contactEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
_ = contactEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
_ = contactEntity.Property(e => e.DataStatus).IsRequired(true);
_ = contactEntity.Property(e => e.DataStatus).IsRequired();
//.HasDefaultValue("Active") //Default-Wert wird nicht gesetzt?!? Bug in EF Core?
_ = contactEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
_ = 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(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
_ = contactEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
}
}
@ -84,30 +84,30 @@ namespace Gremlin_BlazorServer.Data.DBClasses
_ = quoteEntity.HasKey(e => e.QuoteId);
_ = quoteEntity.HasMany(d => d.LineItems).WithOne(p => p.Quote).IsRequired(false).OnDelete(DeleteBehavior.Cascade);
_ = quoteEntity.Property(e => e.QuotationNumber).HasColumnType("VARCHAR(255)").IsRequired(true).ValueGeneratedOnAdd();
_ = quoteEntity.Property(e => e.QuotationDate).IsRequired(true).ValueGeneratedOnAdd();
_ = quoteEntity.Property(e => e.QuotationNumber).HasColumnType("VARCHAR(255)").IsRequired().ValueGeneratedOnAdd();
_ = quoteEntity.Property(e => e.QuotationDate).IsRequired().ValueGeneratedOnAdd();
_ = quoteEntity.Property(e => e.ValidUntil);
_ = quoteEntity.Property(e => e.ValidFor).IsRequired(true);
_ = quoteEntity.Property(e => e.ValidFor).IsRequired();
_ = quoteEntity.Ignore("SalesRep");
_ = quoteEntity.Property(e => e.TotalListprice);
_ = quoteEntity.Property(e => e.TotalDiscount);
_ = quoteEntity.Property(e => e.TotalNet);
_ = quoteEntity.Property(e => e.VAT);
_ = 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.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(true);
_ = quoteEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
_ = quoteEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
_ = quoteEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active"); ;
_ = quoteEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
_ = quoteEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
_ = 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()");
}
}
@ -116,33 +116,33 @@ namespace Gremlin_BlazorServer.Data.DBClasses
public void Configure(EntityTypeBuilder<LineItem> entity)
{
_ = entity.HasKey(e => e.LineItemId);
_ = entity.HasOne(p => p.Quote).WithMany(d => d.LineItems).HasForeignKey(fk => fk.QuoteId).IsRequired(true).OnDelete(DeleteBehavior.Cascade);
_ = entity.HasOne(p => p.Quote).WithMany(d => d.LineItems).HasForeignKey(fk => fk.QuoteId).IsRequired().OnDelete(DeleteBehavior.Cascade);
_ = entity.Property(e => e.Position).IsRequired(true);
_ = entity.Property(e => e.Amount).IsRequired(true);
_ = entity.Property(e => e.ProductNumber).IsRequired(true);
_ = entity.Property(e => e.Position).IsRequired();
_ = entity.Property(e => e.Amount).IsRequired();
_ = entity.Property(e => e.ProductNumber).IsRequired();
_ = entity.Property(e => e.OptionNumber).HasDefaultValue("");
_ = entity.Property(e => e.SapShortDescription).HasDefaultValue("");
_ = entity.Property(e => e.SapLongDescription).HasDefaultValue("");
_ = entity.Property(e => e.ProductLine).HasDefaultValue("");
_ = entity.Property(e => e.TotalDiscount).IsRequired(true).HasDefaultValue(0);
_ = entity.Property(e => e.SalesDiscount).IsRequired(true).HasDefaultValue(0);
_ = entity.Property(e => e.PromotionalDiscount).IsRequired(true).HasDefaultValue(0);
_ = entity.Property(e => e.ContractualDiscount).IsRequired(true).HasDefaultValue(0);
_ = entity.Property(e => e.DemoDiscount).IsRequired(true).HasDefaultValue(0);
_ = entity.Property(e => e.ListPrice).IsRequired(true);
_ = entity.Property(e => e.ExtendedListPrice).IsRequired(true);
_ = entity.Property(e => e.NetPrice).IsRequired(true);
_ = entity.Property(e => e.Total).IsRequired(true);
_ = entity.Property(e => e.TotalDiscount).IsRequired().HasDefaultValue(0);
_ = entity.Property(e => e.SalesDiscount).IsRequired().HasDefaultValue(0);
_ = entity.Property(e => e.PromotionalDiscount).IsRequired().HasDefaultValue(0);
_ = entity.Property(e => e.ContractualDiscount).IsRequired().HasDefaultValue(0);
_ = entity.Property(e => e.DemoDiscount).IsRequired().HasDefaultValue(0);
_ = entity.Property(e => e.ListPrice).IsRequired();
_ = entity.Property(e => e.ExtendedListPrice).IsRequired();
_ = entity.Property(e => e.NetPrice).IsRequired();
_ = entity.Property(e => e.Total).IsRequired();
_ = entity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
_ = entity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
_ = entity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
_ = entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
_ = entity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
_ = entity.Property(e => e.DataVersionComment).HasDefaultValue("");
_ = entity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
_ = entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
_ = entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
_ = entity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active");
_ = entity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
_ = entity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
}
}
@ -151,28 +151,28 @@ namespace Gremlin_BlazorServer.Data.DBClasses
public void Configure(EntityTypeBuilder<Product> productEntity)
{
_ = productEntity.HasKey(e => e.ProductId);
_ = productEntity.HasOne(d => d.CustomDescription).WithMany(p => p.Products).HasForeignKey("CustomDescriptionId").IsRequired(true).OnDelete(DeleteBehavior.SetNull);
_ = productEntity.HasOne(p => p.ProductLine).WithMany(d => d.Products).HasForeignKey("ProductLineCode").IsRequired(true).OnDelete(DeleteBehavior.Restrict);
_ = productEntity.HasOne(d => d.CustomDescription).WithMany(p => p.Products).HasForeignKey("CustomDescriptionId").IsRequired().OnDelete(DeleteBehavior.SetNull);
_ = productEntity.HasOne(p => p.ProductLine).WithMany(d => d.Products).HasForeignKey("ProductLineCode").IsRequired().OnDelete(DeleteBehavior.Restrict);
_ = productEntity.Property(e => e.CustomDescriptionId).IsRequired(true);
_ = productEntity.Property(e => e.CustomDescriptionId).IsRequired();
_ = productEntity.Property(e => e.ProductNumber).IsRequired(true);
_ = productEntity.Property(e => e.ProductNumber).IsRequired();
_ = productEntity.Property(e => e.OptionNumber).HasDefaultValue("");
_ = productEntity.Property(e => e.SapShortDescription).HasDefaultValue("");
_ = productEntity.Property(e => e.SapLongDescription).HasDefaultValue("");
_ = productEntity.Property(e => e.Weight).HasDefaultValue(0);
_ = productEntity.Property(e => e.ProductStatus).HasDefaultValue("Active");
_ = productEntity.Property(e => e.IntroductionDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
_ = productEntity.Property(e => e.ListPrice).IsRequired(true);
_ = productEntity.Property(e => e.ListPrice).IsRequired();
_ = productEntity.Property(e => e.DataCreationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
_ = productEntity.Property(e => e.DataValidFrom).HasColumnType("DATETIME").HasDefaultValueSql("CURRENT_TIMESTAMP").ValueGeneratedOnAdd();
_ = productEntity.Property(e => e.DataValidUntil).HasColumnType("DATETIME").HasDefaultValueSql("'9999-12-31 23:59:59.000000'").ValueGeneratedOnAdd();
_ = productEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired(true);
_ = productEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
_ = productEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
_ = productEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
_ = productEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
_ = productEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
_ = productEntity.Property(e => e.DataStatus).IsRequired().HasDefaultValue("Active");
_ = productEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken();
_ = productEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired().HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
}
}
@ -182,11 +182,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
{
_ = customDescriptionEntity.HasKey(e => e.CustomDescriptionId);
_ = customDescriptionEntity.HasMany(p => p.Products).WithOne(d => d.CustomDescription).IsRequired(false);
_ = customDescriptionEntity.HasOne(p => p.Supplier).WithMany(d => d.CustomDescriptions).IsRequired(true);
_ = customDescriptionEntity.HasOne(p => p.Supplier).WithMany(d => d.CustomDescriptions).IsRequired();
_ = customDescriptionEntity.Property(e => e.ProductNumber).IsRequired(true);
_ = customDescriptionEntity.Property(e => e.ProductNumber).IsRequired();
_ = customDescriptionEntity.Property(e => e.OptionNumber).HasDefaultValue("");
_ = customDescriptionEntity.Property(e => e.Heading).IsRequired(true);
_ = customDescriptionEntity.Property(e => e.Heading).IsRequired();
_ = customDescriptionEntity.Property(e => e.DescriptionText).HasDefaultValue("");
_ = customDescriptionEntity.Property(e => e.CoverletterText).HasDefaultValue("");
_ = customDescriptionEntity.Property(e => e.Notes).HasDefaultValue("");
@ -194,11 +194,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
_ = 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(true);
_ = customDescriptionEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
_ = customDescriptionEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
_ = customDescriptionEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
_ = customDescriptionEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
_ = customDescriptionEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
_ = 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()");
}
}
@ -206,18 +206,18 @@ namespace Gremlin_BlazorServer.Data.DBClasses
{
public void Configure(EntityTypeBuilder<ProductLine> productLineEntity)
{
_ = productLineEntity.HasMany(p => p.Products).WithOne(d => d.ProductLine).IsRequired(true).OnDelete(DeleteBehavior.Restrict);
_ = productLineEntity.HasMany(p => p.Products).WithOne(d => d.ProductLine).IsRequired().OnDelete(DeleteBehavior.Restrict);
_ = productLineEntity.Property(e => e.ProductLineDescription).IsRequired(true);
_ = 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(true);
_ = productLineEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
_ = productLineEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
_ = productLineEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
_ = productLineEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
_ = productLineEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
_ = 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()");
}
}
@ -227,17 +227,17 @@ namespace Gremlin_BlazorServer.Data.DBClasses
{
//entity.HasKey(e => e.AccountTypeCode);
//entity.HasMany(p => p.Accounts).WithOne(d => d.AccountType); //already defined in class Account
_ = accountTypeEntity.Property(e => e.AccountTypeCode).IsRequired(true).HasColumnType("Char(3)");
_ = accountTypeEntity.Property(e => e.AccountTypeDescription).HasColumnType("Varchar(1000)").IsRequired(true);
_ = 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(true);
_ = accountTypeEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
_ = accountTypeEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
_ = accountTypeEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
_ = accountTypeEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
_ = accountTypeEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
_ = 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()");
}
}
@ -248,16 +248,16 @@ namespace Gremlin_BlazorServer.Data.DBClasses
//entity.HasKey(e => e.SubMarketCode);
//entity.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(true);
_ = 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(true);
_ = subMarketEntity.Property(e => e.DataVersionNumber).HasDefaultValue(1).IsRequired();
_ = subMarketEntity.Property(e => e.DataVersionComment).HasDefaultValue("");
_ = subMarketEntity.Property(e => e.DataStatus).IsRequired(true).HasDefaultValue("Active");
_ = subMarketEntity.Property(e => e.DataModificationDate).HasColumnType("TIMESTAMP").HasDefaultValueSql("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").ValueGeneratedOnAddOrUpdate().IsConcurrencyToken(true);
_ = subMarketEntity.Property(e => e.DataModificationByUser).HasColumnType("TINYTEXT").IsRequired(true).HasDefaultValueSql("ON INSERT CURRENT_USER() ON UPDATE CURRENT_USER()");
_ = 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()");
}
}
@ -265,30 +265,30 @@ namespace Gremlin_BlazorServer.Data.DBClasses
{
public void Configure(EntityTypeBuilder<RegisteredUser> registeredUserEntity)
{
_ = registeredUserEntity.HasKey(e => e.RegisteredUserID);
_ = registeredUserEntity.HasKey(e => e.RegisteredUserId);
_ = registeredUserEntity.HasMany(d => d.RUSettings).WithOne(p => p.RegisteredUser).IsRequired(true);
_ = registeredUserEntity.Property(e => e.UserName).IsRequired(true);
_ = registeredUserEntity.Property(e => e.PasswordHash).IsRequired(true);
_ = 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(true);
_ = 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 class RuSettingsConfiguration : IEntityTypeConfiguration<RuSettings>
{
public void Configure(EntityTypeBuilder<RUSettings> rUSettingsEntitity)
public void Configure(EntityTypeBuilder<RuSettings> rUSettingsEntitity)
{
_ = rUSettingsEntitity.HasKey(e => e.RUSettingsID);
_ = rUSettingsEntitity.HasKey(e => e.RuSettingsId);
_ = rUSettingsEntitity.HasOne(d => d.RegisteredUser).WithMany(p => p.RUSettings).IsRequired(true);
_ = rUSettingsEntitity.Property(e => e.SettingKey).IsRequired(true);
_ = rUSettingsEntitity.Property(e => e.SettingValue).IsRequired(true);
_ = 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(true);
_ = 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()");
}
}

@ -14,47 +14,32 @@ namespace Gremlin_BlazorServer.Data.DBClasses
//Private members
private static readonly DateTime FarInTheFuture = DateTime.Parse("2050-12-31t00:00:00.000000z", CultureInfo.CurrentCulture);
private static Encoding encoding = Encoding.UTF8;
private static TextFieldParser csvParser = new(Filepath, encoding, true);
private static string filepath = string.Empty;
internal static GremlinContext db = new();
private static Encoding _encoding = Encoding.UTF8;
private static TextFieldParser _csvParser = new(Filepath, _encoding, true);
private static readonly GremlinContext Db = new();
//Public properties
public static string Filepath
{
get => filepath;
set
{
filepath = value;
if (encoding != null)
{
TextFieldParser _csvParser = new(Filepath, encoding, true);
_csvParser.SetDelimiters(Separators);
_csvParser.HasFieldsEnclosedInQuotes = true;
}
}
}
private static string Filepath { get; set; } = string.Empty;
public static string[] Separators
private static string[] Separators
{
get => csvParser.Delimiters!;
get => _csvParser.Delimiters!;
set
{
if (value.Length > 0)
{
csvParser.SetDelimiters(value);
_csvParser.SetDelimiters(value);
}
}
}
public static bool DataHasHeadings { get; set; }
public static Encoding Encoding
private static Encoding Encoding
{
get => encoding;
set
{
encoding = value;
_encoding = value;
ResetParser();
}
}
@ -101,34 +86,34 @@ namespace Gremlin_BlazorServer.Data.DBClasses
//Public methods
public static void SetFilepath()
private static void SetFilepath()
{
//Filepath = FileIO.GetFilepathFromUser();
}
public static void ResetParser()
private static void ResetParser()
{
if (Filepath != "")
{
TextFieldParser _newParser = new(Filepath, encoding);
_newParser.SetDelimiters(Separators);
_newParser.HasFieldsEnclosedInQuotes = true;
csvParser = _newParser;
TextFieldParser newParser = new(Filepath, _encoding);
newParser.SetDelimiters(Separators);
newParser.HasFieldsEnclosedInQuotes = true;
_csvParser = newParser;
}
}
public static bool Run(string filepath, string separator, string encoding)
{
GenericImporter.filepath = filepath.Replace(@"\\", @"\");
Filepath = filepath.Replace(@"\\", @"\");
try
{
Encoding = Encoding.GetEncoding(encoding);
}
catch (Exception)
{
Encoding = FileService.GetEncoding(GenericImporter.filepath);
Encoding = FileService.GetEncoding(Filepath);
}
Separators = new string[] { separator };
Separators = new[] { separator };
return ImportFile();
}
@ -140,16 +125,16 @@ namespace Gremlin_BlazorServer.Data.DBClasses
return false;
}
GenericImporter.filepath = filepath.Replace(@"\\", @"\");
Filepath = filepath.Replace(@"\\", @"\");
try
{
Encoding = Encoding.GetEncoding(encoding);
}
catch (Exception)
{
Encoding = FileService.GetEncoding(GenericImporter.filepath);
Encoding = FileService.GetEncoding(Filepath);
}
Separators = new string[] { separator };
Separators = new[] { separator };
return await Task.Run(ImportFile);
}
@ -161,12 +146,12 @@ namespace Gremlin_BlazorServer.Data.DBClasses
return string.Empty;
}
string[] candidates = new string[] { "|", ",", ";" };
string[] candidates = new[] { "|", ",", ";" };
int numberOfCandidates = candidates.Length;
int numberOfLinesToEvaluate = 100;
const int numberOfLinesToEvaluate = 100;
int[,] score = new int[numberOfLinesToEvaluate, numberOfCandidates];
GenericImporter.filepath = filepath.Replace(@"\\", @"\");
Filepath = filepath.Replace(@"\\", @"\");
//if (csvParser == null)
//{
// try
@ -179,14 +164,13 @@ namespace Gremlin_BlazorServer.Data.DBClasses
// }
//}
using (csvParser)
using (_csvParser)
{
string line;
for (int i = 0; i < numberOfLinesToEvaluate; i++)
{
if (!csvParser.EndOfData)
if (!_csvParser.EndOfData)
{
line = csvParser.ReadLine()!;
string line = _csvParser.ReadLine()!;
for (int j = 0; j < numberOfCandidates; j++)
{
score[i, j] = line.Split(candidates[j]).Length;
@ -196,12 +180,10 @@ namespace Gremlin_BlazorServer.Data.DBClasses
}
List<(string, int, float)> scoreBoard = new(); //Item1 = Separator, Item2 = Score (Anzahl aufeinanderfolgender Zeilen mit gleicher Anzahl von Fields), Item3 = Count (durchschnittliche Anzahl von Fields in Zeile)
int x;
float average;
for (int j = 0; j < numberOfCandidates; j++)
{
x = 0;
average = 0;
int x = 0;
float average = 0;
for (int i = 0; i < numberOfLinesToEvaluate - 1; i++)
{
if (score[i, j] == score[i + 1, j] && score[i, j] > 1)
@ -219,7 +201,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
return scoreBoard.Find(f => f.Item2 == scoreBoard.Max(x => x.Item2) && f.Item3 == scoreBoard.Max(x => x.Item3)).Item1;
}
public static bool ImportFile()
private static bool ImportFile()
//Ein (möglichst) generischer Importer
//1. Dateipfad erfassen
//2. Column <-> Property Mapping
@ -227,17 +209,17 @@ namespace Gremlin_BlazorServer.Data.DBClasses
//4. Daten einlesen, konvertieren, validieren, Metadaten setzen und alles in Liste(n) speichern
//5. Datenliste(n) in DB speichern
{
if (filepath == "")
if (Filepath == "")
{
SetFilepath();
}
if (filepath == "")
if (Filepath == "")
{
return false;
}
using (csvParser)
using (_csvParser)
{
//für geneerischen Code:
//int numberOfLines = File.ReadAllLines(filepath).Length;
@ -245,9 +227,9 @@ namespace Gremlin_BlazorServer.Data.DBClasses
//dynamische Spaltenzuordnung in Dictonary speichern
string[] fields = csvParser.ReadFields()!;
Dictionary<string, string> MappingDictionary = ReadMappingDictionaryFromFile();
Dictionary<string, int> mappingTable = MapDataHeading(fields, MappingDictionary);
string[] fields = _csvParser.ReadFields()!;
Dictionary<string, string> mappingDictionary = ReadMappingDictionaryFromFile();
Dictionary<string, int> mappingTable = MapDataHeading(fields, mappingDictionary);
//determine data type to be imported
DataIdentificator dataIdentificator = new(mappingTable);
@ -262,12 +244,12 @@ namespace Gremlin_BlazorServer.Data.DBClasses
return detectedDataTypes[0] switch
{
"ProductLine" => ImportProductLine(csvParser, mappingTable),
"AccountType" => ImportAccountType(csvParser, mappingTable),
"SubMarket" => ImportSubMarket(csvParser, mappingTable),
"ProductLine" => ImportProductLine(_csvParser, mappingTable),
"AccountType" => ImportAccountType(_csvParser, mappingTable),
"SubMarket" => ImportSubMarket(_csvParser, mappingTable),
"Account" => ImportAccounts(mappingTable),
"Contact" => ImportContacts(mappingTable),
"LSAG" => ImportLSAG(mappingTable),
"LSAG" => ImportLsag(mappingTable),
"Product" => ImportProducts(mappingTable),
"CustomDescription" => ImportCustomDescriptions(),// mappingTable);
_ => false,
@ -277,7 +259,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
public static bool ImportFile(string filepath)
{
GenericImporter.filepath = filepath;
Filepath = filepath;
return ImportFile();
}
@ -285,16 +267,16 @@ namespace Gremlin_BlazorServer.Data.DBClasses
{
List<CustomDescription> cDsReadFromFile = new(2500);
Encoding = Encoding.GetEncoding("UTF-8"); //Custom-Descriptions-CSV hat festes Encoding.
using (csvParser)
using (_csvParser)
{
// Skip the row with the column names:
_ = csvParser.ReadLine();
_ = _csvParser.ReadLine();
while (!csvParser.EndOfData)
while (!_csvParser.EndOfData)
{
// Read current line fields, pointer moves to the next line.
string[] fields = csvParser.ReadFields()!;
CustomDescription ImportedCD = new()
string[] fields = _csvParser.ReadFields()!;
CustomDescription importedCd = new()
{
ProductNumber = fields[0],
OptionNumber = fields[1],
@ -312,10 +294,10 @@ namespace Gremlin_BlazorServer.Data.DBClasses
AccountName = fields[2] is "" or "RB" ? "Agilent Technologies" : fields[2]
}
};
ImportedCD.DataCreationDate = ImportedCD.DataValidFrom = ImportedCD.DataModificationDate = DateTime.Now;
ImportedCD.DataVersionNumber = 1;
importedCd.DataCreationDate = importedCd.DataValidFrom = importedCd.DataModificationDate = DateTime.Now;
importedCd.DataVersionNumber = 1;
cDsReadFromFile.Add(ImportedCD);
cDsReadFromFile.Add(importedCd);
}
//Eingelesenen Custum Desciptions in DB schreiben:
@ -328,17 +310,17 @@ namespace Gremlin_BlazorServer.Data.DBClasses
{
//Step 1a
List<Product> thirdPartyProductsFromImportedCDs = new();
foreach (CustomDescription CD in cDsReadFromFile)
foreach (CustomDescription cd in cDsReadFromFile)
{
if (CD.Supplier.AccountName != "Agilent Technologies")
if (cd.Supplier.AccountName != "Agilent Technologies")
{
Product new3PPProduct = new()
Product new3PpProduct = new()
{
CustomDescription = CD,
CustomDescription = cd,
HasBreakPrices = false,
ListPrice = 0,
ProductNumber = CD.ProductNumber,
OptionNumber = CD.OptionNumber,
ProductNumber = cd.ProductNumber,
OptionNumber = cd.OptionNumber,
ProductStatus = Status.Active.ToString(),
SapLongDescription = "",
SapShortDescription = "",
@ -348,11 +330,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
BreakRangeTo = 0,
ProductLine = DbHelper.ResolveProductLine(db, "3P")
};
new3PPProduct.CustomDescription.Supplier = DbHelper.ResolveAccountByName(db, new3PPProduct.CustomDescription.Supplier.AccountName);
_ = MetaDataSetter.ForImport(new3PPProduct, "GenericImporter-Method", "Created at import from Custom Descriptions.");
thirdPartyProductsFromImportedCDs.Add(new3PPProduct);
new3PpProduct.CustomDescription.Supplier = DbHelper.ResolveAccountByName(db, new3PpProduct.CustomDescription.Supplier.AccountName);
_ = MetaDataSetter.ForImport(new3PpProduct, "GenericImporter-Method", "Created at import from Custom Descriptions.");
thirdPartyProductsFromImportedCDs.Add(new3PpProduct);
}
};
}
//Step 1b
db.Products.AddRange(thirdPartyProductsFromImportedCDs); //Imports both the products and the associated custom descriptions!
@ -360,45 +342,33 @@ namespace Gremlin_BlazorServer.Data.DBClasses
// Produkt aus DB laden, damit der Datensatz vom Context verfolgt wird und EF Core nicht versucht, diesen standardmäßig neu anzulegen.
//Step 2
List<CustomDescription> importedCDsWithEFReferences = new(100000);
List<CustomDescription> cDsWithoutEFReferences = new(100); //nur zur Kontrolle, wird nicht verwendet.
List<CustomDescription> importedCDsWithEfReferences = new(100000);
List<CustomDescription> cDsWithoutEfReferences = new(100); //nur zur Kontrolle, wird nicht verwendet.
List<Product> productsInDb = db.Products.ToList();
Account agilent = db.Accounts.Where(a => a.AccountName == "Agilent Technologies").Single();
Account agilent = db.Accounts.Single(a => a.AccountName == "Agilent Technologies");
foreach (CustomDescription cD in cDsReadFromFile)
{
if (cD.Products == null) { continue; }
//Skip Desciptions, if it has been already imported above (as part from 3PP)
if (thirdPartyProductsFromImportedCDs.Intersect(cD.Products).Any()) { continue; }
//Establish EF Reference. If no PN/Opt found, then skip this custom description.
//CD.Product = GetProduct(db, CD.ProductNumber, CD.OptionNumber); //ResolveXY-functions return null, if no match is found in db.
cD.Products = productsInDb.Where(product => product.ProductNumber == cD.ProductNumber && product.OptionNumber == cD.OptionNumber).ToList();
if (cD.Products == null)
{
cDsWithoutEFReferences.Add(cD);
continue;
}
//Establish EF Reference: If no Supplier-Account found, then skip this custom description (shouldn't happen), else set Supplier to Agilent (3PP-Supplier have been processed before and their products should not be part of this list).
if (cD.Supplier == null)
{
cDsWithoutEFReferences.Add(cD);
continue;
}
cD.Supplier = agilent;
//prepare properties
_ = MetaDataSetter.ForImport(cD, "GenericImporter-Method", "Initial import by CSV Importer (Function GenericImporter.ImportCustomDescriptions)");
//add to final list of CDs, that will go into the db.
importedCDsWithEFReferences.Add(cD);
importedCDsWithEfReferences.Add(cD);
}
db.CustomDescriptions.AddRange(importedCDsWithEFReferences);
db.CustomDescriptions.AddRange(importedCDsWithEfReferences);
_ = db.SaveChanges();
//Bestätigung senden
Debug.WriteLine($"Es wurden {importedCDsWithEFReferences.Count} eigene Beschreibungen erfolgreich der Datenbank hinzugefügt.{Environment.NewLine}Es wurden {thirdPartyProductsFromImportedCDs.Count} 3PP-Produkte neu angelegt.");
Debug.WriteLine($"Es wurden {importedCDsWithEfReferences.Count} eigene Beschreibungen erfolgreich der Datenbank hinzugefügt.{Environment.NewLine}Es wurden {thirdPartyProductsFromImportedCDs.Count} 3PP-Produkte neu angelegt.");
}
return true;
}
@ -406,61 +376,46 @@ namespace Gremlin_BlazorServer.Data.DBClasses
private static bool ImportProducts(Dictionary<string, int> mappingTable)
{
List<Product> ProductsReadFromFile = new(ParseProductFile(mappingTable));
return InsertProducts(ProductsReadFromFile);
List<Product> productsReadFromFile = new(ParseProductFile(mappingTable));
return InsertProducts(productsReadFromFile);
}
private static bool InsertProducts(List<Product> products)
{
using (GremlinContext db = new())
using GremlinContext db = new();
List<ProductLine> productLines = db.ProductLines.ToList();
foreach (Product product in products)
{
List<ProductLine> productLines = db.ProductLines.ToList();
foreach (Product product in products)
{
//var query = db.ProductLines
// .Where(a => a.ProductLineAbbreviation == product.ProductLine.ProductLineAbbreviation)
// .First();
//product.ProductLine = query;
//product.ProductLine = ResolveProductLine(db, product.ProductLine.ProductLineAbbreviation);
product.ProductLine = productLines.Find(x => x.ProductLineCode == product.ProductLine.ProductLineCode) ?? new ProductLine();
_ = MetaDataSetter.ForImport(product, "GenericImporter-Method");
}
db.Products.AddRange(products);
_ = db.SaveChanges();
//Bestätigung senden
Debug.WriteLine($"Es wurden {products.Count} Produkte erfolgreich der Datenbank hinzugefügt.");
return true;
//var query = db.ProductLines
// .Where(a => a.ProductLineAbbreviation == product.ProductLine.ProductLineAbbreviation)
// .First();
//product.ProductLine = query;
//product.ProductLine = ResolveProductLine(db, product.ProductLine.ProductLineAbbreviation);
product.ProductLine = productLines.Find(x => x.ProductLineCode == product.ProductLine.ProductLineCode) ?? new ProductLine();
_ = MetaDataSetter.ForImport(product, "GenericImporter-Method");
}
db.Products.AddRange(products);
_ = db.SaveChanges();
//Bestätigung senden
Debug.WriteLine($"Es wurden {products.Count} Produkte erfolgreich der Datenbank hinzugefügt.");
return true;
}
private static List<Product> ParseProductFile(Dictionary<string, int> columnNumberOf)
///Importiert Produkt-Daten aus CSV (erstellt aus PriceSurfer-CPL)
/// - Encoding: Latin1
/// - Separator = ;
/// - fixe Spaltenzahl und -folge (Überschriften werden nicht untersucht/verwendet):
/// 1) Position = ID/PK
/// 2) Partnumber
/// 3) Option
/// 4) (Short) Description
/// 5) Current Month Price (EUR)
/// 6) ProductLineID
/// 7) Status
/// 8) (Long) Description
///Kommentarzeichen: # (hardcoded, string array)
{
List<Product> results = new(100000);
using (csvParser)
using (_csvParser)
{
while (!csvParser.EndOfData)
while (!_csvParser.EndOfData)
{
// Read current line fields, pointer moves to the next line.
Product ImportedProduct = new()
Product importedProduct = new()
{
ProductLine = new()
};
string[] fields = csvParser.ReadFields()!;
string[] fields = _csvParser.ReadFields()!;
//Kontrolle, ob Trennzeichen in Daten vorhanden ist:
if (fields.Length > 27) //27 ist der Normalfall
@ -498,68 +453,65 @@ namespace Gremlin_BlazorServer.Data.DBClasses
//fields[23] = End of Production Date
//fields[24] = End of Support Date
ImportedProduct.ProductNumber = fields[columnNumberOf["ProductNumber"]];
importedProduct.ProductNumber = fields[columnNumberOf["ProductNumber"]];
if (fields[columnNumberOf["OptionNumber"]].Length == 4) //Optionsnummer mit führendem Apostroph
{
ImportedProduct.OptionNumber = fields[columnNumberOf["OptionNumber"]].Substring(1); //schneidet erstes Zeichen/Apostroph weg
importedProduct.OptionNumber = fields[columnNumberOf["OptionNumber"]].Substring(1); //schneidet erstes Zeichen/Apostroph weg
}
else if (fields[columnNumberOf["OptionNumber"]].Length == 3) //3-stellige Optionsnummer übernehmen; keine Aktion bei leerem Feld (keine Optionsnummer)
{
ImportedProduct.OptionNumber = fields[columnNumberOf["OptionNumber"]];
importedProduct.OptionNumber = fields[columnNumberOf["OptionNumber"]];
}
ImportedProduct.SapShortDescription = fields[columnNumberOf["SapShortDescription"]];
importedProduct.SapShortDescription = fields[columnNumberOf["SapShortDescription"]];
ImportedProduct.ListPrice = decimal.Parse(fields[columnNumberOf["ListPrice"]], new CultureInfo("de-de")); //parsing! compare with old value (either from CSV or from DB) -> price change?
importedProduct.ListPrice = decimal.Parse(fields[columnNumberOf["ListPrice"]], new CultureInfo("de-de")); //parsing! compare with old value (either from CSV or from DB) -> price change?
//if (fields[columnNumberOf["ListPrice"]] != "")
// if (decimal.Parse(fields[columnNumberOf["ListPrice"]], new CultureInfo("de-de")) != ImportedProduct.ListPrice)
// listpriceHasChanged = true;
ImportedProduct.BreakRangeFrom = fields[columnNumberOf["BreakRangeFrom"]] == "" ? 0 : Convert.ToInt32(fields[columnNumberOf["BreakRangeFrom"]]);
ImportedProduct.HasBreakPrices = ImportedProduct.BreakRangeFrom > 0;
ImportedProduct.BreakRangeTo = fields[columnNumberOf["BreakRangeTo"]] is "" or "+" ? 0 : Convert.ToInt32(fields[columnNumberOf["BreakRangeTo"]]); //erfasst sowohl Produkte ohne Break-Preise ("") als auch "+" bei Mengenangaben a la "100+" (= von 100 bis unendlich)
importedProduct.BreakRangeFrom = fields[columnNumberOf["BreakRangeFrom"]] == "" ? 0 : Convert.ToInt32(fields[columnNumberOf["BreakRangeFrom"]]);
importedProduct.HasBreakPrices = importedProduct.BreakRangeFrom > 0;
importedProduct.BreakRangeTo = fields[columnNumberOf["BreakRangeTo"]] is "" or "+" ? 0 : Convert.ToInt32(fields[columnNumberOf["BreakRangeTo"]]); //erfasst sowohl Produkte ohne Break-Preise ("") als auch "+" bei Mengenangaben a la "100+" (= von 100 bis unendlich)
ImportedProduct.ProductLine.ProductLineCode = fields[columnNumberOf["ProductLineCode"]];
importedProduct.ProductLine.ProductLineCode = fields[columnNumberOf["ProductLineCode"]];
switch (fields[columnNumberOf["ProductStatus"]])
{
case "Active":
ImportedProduct.DataStatus = Status.Active.ToString();
ImportedProduct.ProductStatus = Status.Active.ToString();
importedProduct.DataStatus = Status.Active.ToString();
importedProduct.ProductStatus = Status.Active.ToString();
break;
case "New Product" or "New":
ImportedProduct.DataStatus = Status.Active.ToString();
ImportedProduct.ProductStatus = Status.New.ToString();
importedProduct.DataStatus = Status.Active.ToString();
importedProduct.ProductStatus = Status.New.ToString();
break;
case "Price Changed":
ImportedProduct.DataStatus = Status.Active.ToString();
ImportedProduct.ProductStatus = Status.PriceUpdated.ToString();
importedProduct.DataStatus = Status.Active.ToString();
importedProduct.ProductStatus = Status.PriceUpdated.ToString();
break;
default:
ImportedProduct.DataStatus = Status.StatusUpdated.ToString();
importedProduct.DataStatus = Status.StatusUpdated.ToString();
break;
}
if (fields[columnNumberOf["Weight"]] != null)
{
ImportedProduct.Weight = ParseWeight(fields[columnNumberOf["Weight"]]);
}
importedProduct.Weight = ParseWeight(fields[columnNumberOf["Weight"]]);
if (fields[columnNumberOf["WeightUnit"]] == "G")
{
ImportedProduct.Weight /= 1000; //Umrechnung g in kg
importedProduct.Weight /= 1000; //Umrechnung g in kg
}
if (fields[columnNumberOf["IntroductionDate"]] != "")
{
ImportedProduct.IntroductionDate = DateTime.Parse(fields[columnNumberOf["IntroductionDate"]]);
importedProduct.IntroductionDate = DateTime.Parse(fields[columnNumberOf["IntroductionDate"]]);
}
ImportedProduct.SapLongDescription = fields[columnNumberOf["SapLongDescription"]];
importedProduct.SapLongDescription = fields[columnNumberOf["SapLongDescription"]];
results.Add(ImportedProduct);
results.Add(importedProduct);
}
}
@ -586,46 +538,45 @@ namespace Gremlin_BlazorServer.Data.DBClasses
}
private static bool ImportLSAG(Dictionary<string, int> mappingTable)
private static bool ImportLsag(Dictionary<string, int> mappingTable)
{
bool result;
result = ImportAccounts(mappingTable);
bool result = ImportAccounts(mappingTable);
ResetParser();
_ = csvParser.ReadFields(); //Skip Heading
_ = _csvParser.ReadFields(); //Skip Heading
result = result && ImportContacts(mappingTable);
return result;
}
public static bool ImportContacts(Dictionary<string, int> columnNumberOf)
private static bool ImportContacts(Dictionary<string, int> columnNumberOf)
{
List<Contact> ContactsReadFromFile = new(8000);
using (csvParser)
List<Contact> contactsReadFromFile = new(8000);
using (_csvParser)
{
while (!csvParser.EndOfData)
while (!_csvParser.EndOfData)
{
Contact ImportedContact = new();
string[] fields = csvParser.ReadFields()!;
Contact importedContact = new();
string[] fields = _csvParser.ReadFields()!;
//No conversion
ImportedContact.AcademicTitle = fields[columnNumberOf["AcademicTitle"]];
ImportedContact.FirstName = fields[columnNumberOf["FirstName"]];
ImportedContact.LastName = fields[columnNumberOf["LastName"]];
ImportedContact.EMail = fields[columnNumberOf["EMail"]];
ImportedContact.Department = fields[columnNumberOf["Department"]];
ImportedContact.Room = fields[columnNumberOf["Room"]];
ImportedContact.PhoneNumber = fields[columnNumberOf["PhoneNumber"]];
ImportedContact.Function = fields[columnNumberOf["Function"]];
ImportedContact.MobileNumber = fields[columnNumberOf["MobileNumber"]];
importedContact.AcademicTitle = fields[columnNumberOf["AcademicTitle"]];
importedContact.FirstName = fields[columnNumberOf["FirstName"]];
importedContact.LastName = fields[columnNumberOf["LastName"]];
importedContact.EMail = fields[columnNumberOf["EMail"]];
importedContact.Department = fields[columnNumberOf["Department"]];
importedContact.Room = fields[columnNumberOf["Room"]];
importedContact.PhoneNumber = fields[columnNumberOf["PhoneNumber"]];
importedContact.Function = fields[columnNumberOf["Function"]];
importedContact.MobileNumber = fields[columnNumberOf["MobileNumber"]];
//Convert Gender
ImportedContact.Gender = fields[columnNumberOf["Gender"]] == "M"
importedContact.Gender = fields[columnNumberOf["Gender"]] == "M"
? (byte)Gender.Male
: fields[columnNumberOf["Gender"]] == "F"
? (byte)Gender.Female
: (byte)Gender.Unknown;
//Convert OptIn Status
ImportedContact.OptInStatus = fields[columnNumberOf["OptInStatus"]] switch
importedContact.OptInStatus = fields[columnNumberOf["OptInStatus"]] switch
{
"Opt In" => true,
"Opt Out" => false,
@ -635,7 +586,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
//Convert "SAP Contact Number"
try
{
ImportedContact.SAPContactNumber = Convert.ToInt32(fields[columnNumberOf["SAPContactNumber"]], CultureInfo.CurrentCulture);
importedContact.SapContactNumber = Convert.ToInt32(fields[columnNumberOf["SAPContactNumber"]], CultureInfo.CurrentCulture);
}
catch (FormatException ex)
{
@ -668,30 +619,30 @@ namespace Gremlin_BlazorServer.Data.DBClasses
int year = Convert.ToInt32(fields[columnNumberOf["SAPContactCreationDate"]].Substring(0, 4), CultureInfo.CurrentCulture);
int month = Convert.ToInt32(fields[columnNumberOf["SAPContactCreationDate"]].Substring(4, 2), CultureInfo.CurrentCulture);
int day = Convert.ToInt32(fields[columnNumberOf["SAPContactCreationDate"]].Substring(6, 2), CultureInfo.CurrentCulture);
ImportedContact.SAPContactCreationDate = new DateTime(year, month, day);
importedContact.SapContactCreationDate = new DateTime(year, month, day);
//Convert "No Phone Calls"
if (fields[columnNumberOf["NoPhoneCalls"]] == "1")
{
ImportedContact.NoPhoneCalls = true;
importedContact.NoPhoneCalls = true;
}
//Convert "No Hardcopy Mailing"
if (fields[columnNumberOf["NoHardcopyMailing"]] == "1")
{
ImportedContact.NoHardcopyMailing = true;
importedContact.NoHardcopyMailing = true;
}
//SAPAccountID in Contact.Notes speichern, um den entsprechenden Account aus DB heraussuchen zu können:
ImportedContact.Notes = fields[columnNumberOf["SAPAccountNumber"]];
importedContact.Notes = fields[columnNumberOf["SAPAccountNumber"]];
ContactsReadFromFile.Add(ImportedContact);
contactsReadFromFile.Add(importedContact);
}
//Eingelesenen Account in DB schreiben:
using (GremlinContext db = new())
{
foreach (Contact contact in ContactsReadFromFile)
foreach (Contact contact in contactsReadFromFile)
{
// AccountID aus DB laden, damit der Datensatz vom Context verfolgt wird und EF Core nicht versucht, diesen standardmäßig neu anzulegen.
contact.Account = DbHelper.ResolveAccountById(db, Convert.ToUInt32(contact.Notes));
@ -700,56 +651,38 @@ namespace Gremlin_BlazorServer.Data.DBClasses
_ = MetaDataSetter.ForImport(contact, "GenericImporter-Method");
}
db.Contacts.AddRange(ContactsReadFromFile);
db.Contacts.AddRange(contactsReadFromFile);
_ = db.SaveChanges();
}
}
//Bestätigung senden
Debug.WriteLine($"Es wurden {ContactsReadFromFile.Count} Contacts erfolgreich der Datenbank hinzugefügt.");
Debug.WriteLine($"Es wurden {contactsReadFromFile.Count} Contacts erfolgreich der Datenbank hinzugefügt.");
return true;
}
public static bool ImportAccounts(Dictionary<string, int> columnNumberOf)
///Importiert Account Daten aus CSV (erstellt aus LSAG_Contact_List_Tool.xlsx)
///
/// - Encoding: Latin1/ISO-8859-1
/// - fixe Spaltenzahl und -folge (Überschriften werden nicht untersucht/verwendet):
/// 1) SAPAccountNumber
/// 2) AccountName
/// 3) ZIP
/// 4) City
/// 5) Street
/// 6) AccountSubMarketCode
/// 7) AccountTypeCode
/// 8) PhoneNumber
/// 9) AccountsCreatedInSAP
///Kommentarzeichen: # (hardcoded, string array)
///Rückgabe 'false' bei Fehler oder User-Abbruch, ansonsten 'true'.
///
///Argumente:
/// 1.
private static bool ImportAccounts(Dictionary<string, int> columnNumberOf)
{
List<Account> AccountsReadFromFile = new(1000);
List<Account> accountsReadFromFile = new(1000);
while (!csvParser.EndOfData)
while (!_csvParser.EndOfData)
{
bool DataHasError = false;
bool dataHasError = false;
// Read current line fields, pointer moves to the next line.
Account ImportedAccount = new();
Account importedAccount = new();
{
ImportedAccount.SubMarket = new();
ImportedAccount.AccountType = new();
ImportedAccount.Contacts = new List<Contact>();
importedAccount.SubMarket = new();
importedAccount.AccountType = new();
importedAccount.Contacts = new List<Contact>();
}
string[] fields = csvParser.ReadFields()!;
string[] fields = _csvParser.ReadFields()!;
//Konvertierung erforderlich:
try
{
ImportedAccount.SAPAccountNumber = Convert.ToUInt32(fields[columnNumberOf["SAPAccountNumber"]]);
importedAccount.SapAccountNumber = Convert.ToUInt32(fields[columnNumberOf["SAPAccountNumber"]]);
}
catch (FormatException ex)
{
@ -780,7 +713,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
try
{
ImportedAccount.ZIP = Convert.ToUInt32(fields[columnNumberOf["ZIP"]]);
importedAccount.Zip = Convert.ToUInt32(fields[columnNumberOf["ZIP"]]);
}
catch (FormatException ex)
{
@ -818,77 +751,73 @@ namespace Gremlin_BlazorServer.Data.DBClasses
int year = Convert.ToInt32(fields[columnNumber].Substring(0, 4));
int month = Convert.ToInt32(fields[columnNumber].Substring(4, 2));
int day = Convert.ToInt32(fields[columnNumber].Substring(6, 2));
ImportedAccount.AccountCreatedInSAPOn = new DateTime(year, month, day);
importedAccount.AccountCreatedInSapOn = new DateTime(year, month, day);
}
}
//Convert City von Großschreibung zu Normalschreibung
ImportedAccount.City = fields[columnNumberOf["City"]].First().ToString() + fields[columnNumberOf["City"]].Substring(1).ToLower();
importedAccount.City = fields[columnNumberOf["City"]].First().ToString() + fields[columnNumberOf["City"]].Substring(1).ToLower();
//keine Konvertierung nötig:
ImportedAccount.AccountName = fields[columnNumberOf["AccountName"]];
ImportedAccount.Street = fields[columnNumberOf["Street"]];
ImportedAccount.SubMarket.SubMarketCode = fields[columnNumberOf["SubMarketCode"]];
ImportedAccount.SubMarket.DataStatus = Status.Active.ToString();
ImportedAccount.AccountType.AccountTypeCode = fields[columnNumberOf["AccountTypeCode"]];
ImportedAccount.AccountType.DataStatus = Status.Active.ToString();
ImportedAccount.PhoneNumber = fields[columnNumberOf["PhoneNumber"]];
ImportedAccount.DataStatus = Status.Active.ToString();
importedAccount.AccountName = fields[columnNumberOf["AccountName"]];
importedAccount.Street = fields[columnNumberOf["Street"]];
importedAccount.SubMarket.SubMarketCode = fields[columnNumberOf["SubMarketCode"]];
importedAccount.SubMarket.DataStatus = Status.Active.ToString();
importedAccount.AccountType.AccountTypeCode = fields[columnNumberOf["AccountTypeCode"]];
importedAccount.AccountType.DataStatus = Status.Active.ToString();
importedAccount.PhoneNumber = fields[columnNumberOf["PhoneNumber"]];
importedAccount.DataStatus = Status.Active.ToString();
//Validierungen:
if (ImportedAccount.AccountName == ""
|| ImportedAccount.City == ""
|| ImportedAccount.Street == ""
|| ImportedAccount.SubMarket.SubMarketCode == ""
|| ImportedAccount.AccountType.AccountTypeCode == ""
|| ImportedAccount.SAPAccountNumber == 0)
if (importedAccount.AccountName == ""
|| importedAccount.City == ""
|| importedAccount.Street == ""
|| importedAccount.SubMarket.SubMarketCode == ""
|| importedAccount.AccountType.AccountTypeCode == ""
|| importedAccount.SapAccountNumber == 0)
{
DataHasError = true;
dataHasError = true;
}
//Validierten Account der Liste hinzufügen:
if (DataHasError == false)
if (dataHasError == false)
{
_ = ImportedAccount.AddIfUniqueTo(AccountsReadFromFile);
_ = importedAccount.AddIfUniqueTo(accountsReadFromFile);
}
}
//Eingelesenen Account in DB schreiben:
DateTime now = DateTime.Now;
foreach (Account account in AccountsReadFromFile)
foreach (Account account in accountsReadFromFile)
{
// AccountType aus DB laden, damit der Datensatz vom Context verfolgt wird und EF Core nicht versucht, diesen standardmäßig neu anzulegen.
AccountType accountType = db.AccountTypes
.Where(a => a.AccountTypeCode == account.AccountType.AccountTypeCode)
.First();
AccountType accountType = Db.AccountTypes
.First(a => a.AccountTypeCode == account.AccountType.AccountTypeCode);
account.AccountType = accountType;
account.AccountType = DbHelper.ResolveAccountType(db, account.AccountType.AccountTypeCode);
account.AccountType = DbHelper.ResolveAccountType(Db, account.AccountType.AccountTypeCode);
SubMarket subMarket = db.SubMarkets
.Where(a => a.SubMarketCode == account.SubMarket.SubMarketCode)
.First();
SubMarket subMarket = Db.SubMarkets
.First(a => a.SubMarketCode == account.SubMarket.SubMarketCode);
account.SubMarket = subMarket;
account.SubMarket = DbHelper.ResolveSubmarket(db, account.SubMarket.SubMarketCode);
account.SubMarket = DbHelper.ResolveSubmarket(Db, account.SubMarket.SubMarketCode);
_ = MetaDataSetter.ForImport(account, "GenericImporter-Method");
//account.DataVersionComment = "Initial import by CSV Importer (Function DbHelper.ImportAccountsFromCSV)";
}
db.Accounts.AddRange(AccountsReadFromFile);
_ = db.SaveChanges();
Db.Accounts.AddRange(accountsReadFromFile);
_ = Db.SaveChanges();
//Bestätigung senden
Debug.WriteLine($"Es wurden {AccountsReadFromFile.Count} Accounts erfolgreich der Datenbank hinzugefügt.");
Debug.WriteLine($"Es wurden {accountsReadFromFile.Count} Accounts erfolgreich der Datenbank hinzugefügt.");
return true;
}
public static bool ImportProductLine(TextFieldParser csvParser, Dictionary<string, int> mappingTable)
private static bool ImportProductLine(TextFieldParser csvParser, Dictionary<string, int> mappingTable)
{
//foreach line in file:
//read seed data, parse/split, save to object with metadata
@ -909,13 +838,13 @@ namespace Gremlin_BlazorServer.Data.DBClasses
}
}
db.ProductLines.AddRange(productLinesReadFromFile);
_ = db.SaveChanges();
Db.ProductLines.AddRange(productLinesReadFromFile);
_ = Db.SaveChanges();
return true;
}
public static bool ImportAccountType(TextFieldParser csvParser, Dictionary<string, int> mappingTable)
private static bool ImportAccountType(TextFieldParser csvParser, Dictionary<string, int> mappingTable)
{
//foreach line in file:
//read seed data, parse/split, save to object with metadata
@ -936,13 +865,13 @@ namespace Gremlin_BlazorServer.Data.DBClasses
}
}
db.AccountTypes.AddRange(accountTypesReadFromFile);
_ = db.SaveChanges();
Db.AccountTypes.AddRange(accountTypesReadFromFile);
_ = Db.SaveChanges();
return true;
}
public static bool ImportSubMarket(TextFieldParser csvParser, Dictionary<string, int> mappingTable)
private static bool ImportSubMarket(TextFieldParser csvParser, Dictionary<string, int> mappingTable)
{
//foreach line in file:
//read seed data, parse/split, save to object with metadata
@ -963,8 +892,8 @@ namespace Gremlin_BlazorServer.Data.DBClasses
}
}
db.SubMarkets.AddRange(subMarketsReadFromFile);
_ = db.SaveChanges();
Db.SubMarkets.AddRange(subMarketsReadFromFile);
_ = Db.SaveChanges();
return true;
}
@ -1000,21 +929,20 @@ namespace Gremlin_BlazorServer.Data.DBClasses
// return Activator.CreateInstance(Gremlin.ToString(), "Gremlin." + detectedDataType).Unwrap();
//}
public static Dictionary<string, string> ReadMappingDictionaryFromFile()
private static Dictionary<string, string> ReadMappingDictionaryFromFile()
{
Dictionary<string, string> result = new();
string fileInput = FileService.ReadResource("MappingDictionary.txt");
string[] lines = fileInput.Split(Environment.NewLine);
foreach (string line in lines)
{
string[] fields;
fields = line.Split("|");
string[] fields = line.Split("|");
result.Add(fields[0], fields[1]);
}
return result;
}
public static Dictionary<string, int> MapDataHeading(string[] headings, Dictionary<string, string> columnPropertyMapping)
private static Dictionary<string, int> MapDataHeading(string[] headings, Dictionary<string, string> columnPropertyMapping)
{
Dictionary<string, int> result = new();
for (int i = 0; i < headings.Length; i++)

@ -1,5 +1,4 @@
using Gremlin_BlazorServer.Data.EntityClasses;
using Gremlin_BlazorServer.Services;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
@ -7,7 +6,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
{
public class GremlinContext : DbContext
{
public DbSet<Contact> Contacts { get; set; }
public DbSet<Contact> Contacts { get; set; }
public DbSet<Account> Accounts { get; set; }
public DbSet<Quote> Quotes { get; set; }
public DbSet<Product> Products { get; set; }
@ -16,7 +15,7 @@ namespace Gremlin_BlazorServer.Data.DBClasses
public DbSet<ProductLine> ProductLines { get; set; }
public DbSet<AccountType> AccountTypes { get; set; }
public DbSet<SubMarket> SubMarkets { get; set; }
public DbSet<RUSettings> RUSettings { get; set; }
public DbSet<RuSettings> RuSettings { get; set; }
public DbSet<RegisteredUser> RegisteredUser { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)

@ -1,13 +0,0 @@
namespace Gremlin_BlazorServer.Data.DBClasses
{
internal class GremlinTypeConverter
{
internal static object Convert(string stringToConvert)
{
//noch nicht implementiert.
//für vollkommen generischen Importer
//
return stringToConvert;
}
}
}

@ -19,28 +19,6 @@ namespace Gremlin_BlazorServer.Data.DBClasses
return entity;
}
public static List<IMetadata> ForImport(
List<IMetadata> entities,
string datamodifiedby = "",
string dataversioncomment = "",
[CallerMemberName] string callername = "")
{
//check if entities implements IMetaData:
//Ist das überhaupt nötig?
if ((entities is IMetadata) == false)
{
//no action / return list unchanged
return entities;
}
//set metadata
foreach (IMetadata entity in entities)
{
_ = SetMetaData(entity, datamodifiedby, dataversioncomment, callername);
}
return entities;
}
private static IMetadata SetMetaData(
IMetadata entity,
string datamodifiedby = "",

@ -17,19 +17,19 @@
public string AccountName { get; set; } = string.Empty;
public string Notes { get; set; } = string.Empty;
public string Street { get; set; } = string.Empty;
public uint ZIP { get; set; }
public uint Zip { get; set; }
public string City { get; set; } = string.Empty;
public string FloorOrBuilding { get; set; } = string.Empty;
public float Longitude { get; set; } = 0;
public float Latitude { get; set; } = 0;
public float Longitude { get; set; }
public float Latitude { get; set; }
public string PhoneNumber { get; set; } = string.Empty;
public string FaxNumber { get; set; } = string.Empty;
public string Webpage { get; set; } = string.Empty;
public string EMail { get; set; } = string.Empty;
//Agilent-specific Properties:
public uint SAPAccountNumber { get; set; }
public DateTime AccountCreatedInSAPOn { get; set; }
public uint SapAccountNumber { get; set; }
public DateTime AccountCreatedInSapOn { get; set; }
//metadata:
public DateTime DataCreationDate { get; set; } = DateTime.Now;
@ -87,14 +87,14 @@
public List<Account> AddIfUniqueTo(List<Account> accounts)
{
if (accounts.Count > 0 && SAPAccountNumber == accounts[accounts.Count - 1].SAPAccountNumber)
if (accounts.Count > 0 && SapAccountNumber == accounts[^1].SapAccountNumber)
{
return accounts;
}
foreach (Account account in accounts)
{
if (SAPAccountNumber == account.SAPAccountNumber)
if (SapAccountNumber == account.SapAccountNumber)
{
return accounts;
}

@ -33,14 +33,14 @@
public bool ValidatedContact { get; set; }
//Agilent-specific Properties:
public int SAPContactNumber { get; set; }
public DateTime SAPContactCreationDate { get; set; }
public DateTime SAPContactModifiedDate { get; set; }
public string SAPJobFunction { get; set; } = string.Empty;
public string SAPProductInterest { get; set; } = string.Empty;
public string SAPApplicationInterest { get; set; } = string.Empty;
public string SAPJobLevel { get; set; } = string.Empty;
public string SAPCompetitiveIBase { get; set; } = string.Empty;
public int SapContactNumber { get; set; }
public DateTime SapContactCreationDate { get; set; }
public DateTime SapContactModifiedDate { get; set; }
public string SapJobFunction { get; set; } = string.Empty;
public string SapProductInterest { get; set; } = string.Empty;
public string SapApplicationInterest { get; set; } = string.Empty;
public string SapJobLevel { get; set; } = string.Empty;
public string SapCompetitiveIBase { get; set; } = string.Empty;
//metadata:
public DateTime DataCreationDate { get; set; } = DateTime.Now;

@ -1,6 +1,6 @@
namespace Gremlin_BlazorServer.Data.EntityClasses
{
public class Enums
public abstract class Enums
{
public enum Status : byte
{
@ -34,7 +34,7 @@
Unknown = 0,
Male = 1,
Female = 2,
divers = 3,
Divers = 3,
}
}

@ -21,15 +21,15 @@
public decimal TotalListprice { get; set; }
public decimal TotalDiscount { get; set; }
public decimal TotalNet { get; set; }
public float VAT { get; set; } = 19f;
public float Vat { get; set; } = 19f;
public decimal TotalGross { get; set; }
public bool QuoteContains3PP { get; set; }
public bool QuoteContainsRB { get; set; }
public bool QuoteContains3Pp { get; set; }
public bool QuoteContainsRb { get; set; }
public string QuoteTemplate { get; set; } = string.Empty;
public int Warranty { get; set; } = 12;
public decimal TotalFreightOnly { get; set; }
public decimal TotalFreight { get; set; }
public decimal TotalVAT { get; set; }
public decimal TotalVat { get; set; }
public decimal Freight { get; set; } = 3;
public bool IsPriceInformation { get; set; }
public bool ShowSinglePrices { get; set; } = true;

@ -1,14 +1,14 @@
namespace Gremlin_BlazorServer.Data.EntityClasses
{
public class RUSettings : IDisposable
public class RuSettings : IDisposable
{
private bool disposedValue;
//primary key
public uint RUSettingsID { get; set; }
public uint RuSettingsId { get; set; }
//forgein key
public uint RegisteredUserID { get; set; }
public uint RegisteredUserId { get; set; }
//navigation properties
public RegisteredUser RegisteredUser { get; set; } = new RegisteredUser();

@ -3,10 +3,10 @@
public class RegisteredUser
{
//primary key
public uint RegisteredUserID { get; set; }
public uint RegisteredUserId { get; set; }
//navigation properties
public IList<RUSettings> RUSettings { get; set; } = new List<RUSettings>();
public IList<RuSettings> RuSettings { get; set; } = new List<RuSettings>();
//class properties
public string UserName { get; set; } = string.Empty;

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Lsag/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

@ -13,7 +13,7 @@
<PackageReference Include="Blazorise.Components" Version="1.1.5" />
<PackageReference Include="Blazorise.DataGrid" Version="1.1.5" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.1.5" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.18.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.1">
<PrivateAssets>all</PrivateAssets>
@ -22,8 +22,8 @@
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.1" />
<PackageReference Include="morelinq" Version="3.3.2" />
<PackageReference Include="MySqlConnector" Version="2.2.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0-alpha.1" />
<PackageReference Include="MySqlConnector" Version="2.3.0-beta.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0-silver.1" />
</ItemGroup>
<ItemGroup>

@ -5,7 +5,7 @@
@using System.Globalization;
@using System.Diagnostics;
@inject AccountTypeService accountTypeService
@inject AccountTypeService AccountTypeService
<h1>AccountTypes</h1>
@ -38,7 +38,7 @@ else
}
@code {
public string searchAccountType = string.Empty;
public string SearchAccountType = string.Empty;
CultureInfo cultureInfo = new("de-DE");
AccountType selectedAccountType = new();
@ -46,7 +46,7 @@ else
protected override async Task OnParametersSetAsync()
{
accountTypes = await Task.Run(() => accountTypeService.GetAllAccountTypesAsync());
accountTypes = await Task.Run(() => AccountTypeService.GetAllAccountTypesAsync());
selectedAccountType = accountTypes.FirstOrDefault()!;
}
}

@ -3,8 +3,8 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject AccountService accountService
@inject NavigationManager navigationManager
@inject AccountService AccountService
@inject NavigationManager NavigationManager
<h2>Add Account</h2>
<hr />
@ -14,7 +14,7 @@
<div class="col-md-8">
<div class="form-group">
<label for="SAPAccountNumber" class="control-label">SAPAccountNumber</label>
<input form="SAPAccountNumber" class="form-control" @bind="@account.SAPAccountNumber" />
<input form="SAPAccountNumber" class="form-control" @bind="@account.SapAccountNumber" />
</div>
<div class="form-group">
<label for="AccountName" class="control-label">AccountName</label>
@ -26,7 +26,7 @@
</div>
<div class="form-group">
<label for="ZIP" class="control-label">ZIP</label>
<input form="ZIP" class="form-control" @bind="@account.ZIP" />
<input form="ZIP" class="form-control" @bind="@account.Zip" />
</div>
<div class="form-group">
<label for="City" class="control-label">City</label>
@ -54,11 +54,11 @@
account.DataModificationByUser = "Gremlin_BlazorServer";
account.AccountType.AccountTypeCode = "SUP";
if (await accountService.InsertAccountAsync(account))
if (await AccountService.InsertAccountAsync(account))
{
navigationManager.NavigateTo("Accounts/Index");
NavigationManager.NavigateTo("Accounts/Index");
}
}
void Cancel() => navigationManager.NavigateTo("Accounts/Index");
void Cancel() => NavigationManager.NavigateTo("Accounts/Index");
}

@ -3,8 +3,8 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject AccountService accountService
@inject NavigationManager navigationManager
@inject AccountService AccountService
@inject NavigationManager NavigationManager
<h2>Delete Employee</h2>
<hr />
@ -26,7 +26,7 @@
</div>
<div class="form-group">
<label>ZIP:</label>
<label>@account.ZIP</label>
<label>@account.Zip</label>
</div>
<div class="form-group">
<label>City:</label>
@ -52,15 +52,15 @@
protected override async Task OnInitializedAsync()
{
account = await Task.Run(() => accountService.GetAccountAsync(Convert.ToUInt32(AccountId)));
account = await Task.Run(() => AccountService.GetAccountAsync(Convert.ToUInt32(AccountId)));
}
protected async void DeleteAccount()
{
await accountService.DeleteAccountAsync(account);
navigationManager.NavigateTo("Accounts/Index");
await AccountService.DeleteAccountAsync(account);
NavigationManager.NavigateTo("Accounts/Index");
}
void Cancel()
{
navigationManager.NavigateTo("Accounts/Index");
NavigationManager.NavigateTo("Accounts/Index");
}
}

@ -3,8 +3,8 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject AccountService accountService
@inject NavigationManager navigationManager
@inject AccountService AccountService
@inject NavigationManager NavigationManager
<h2>Edit Account</h2>
<hr />
@ -18,7 +18,7 @@
</div>
<div class="form-group">
<label for="SAPAccountNumber" class="control-label">SAPAccountNumber</label>
<input form="SAPAccountNumber" class="form-control" @bind="@account.SAPAccountNumber" />
<input form="SAPAccountNumber" class="form-control" @bind="@account.SapAccountNumber" />
</div>
<div class="form-group">
<label for="AccountName" class="control-label">Name</label>
@ -30,7 +30,7 @@
</div>
<div class="form-group">
<label for="ZIP" class="control-label">ZIP</label>
<input form="ZIP" class="form-control" @bind="@account.ZIP" />
<input form="ZIP" class="form-control" @bind="@account.Zip" />
</div>
<div class="form-group">
<label for="City" class="control-label">City</label>
@ -57,14 +57,14 @@
protected override async Task OnInitializedAsync()
{
account = await Task.Run(() => accountService.GetAccountAsync(Convert.ToUInt32(AccountId)));
account = await Task.Run(() => AccountService.GetAccountAsync(Convert.ToUInt32(AccountId)));
}
protected async void UpdateAccount()
{
await accountService.UpdateAccountAsync(account);
navigationManager.NavigateTo("Accounts/Index");
await AccountService.UpdateAccountAsync(account);
NavigationManager.NavigateTo("Accounts/Index");
}
void Cancel() => navigationManager.NavigateTo("Accounts/Index");
void Cancel() => NavigationManager.NavigateTo("Accounts/Index");
}

@ -3,13 +3,13 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject AccountService accountService
@inject AccountService AccountService
<h1>Accounts</h1>
<div class="text-center bg-blue-100">
<input class="border-4 w-1/3 rounded m-6 p-6 h-8
border-blue-300" @bind-value="searchAccount"
border-blue-300" @bind-value="SearchAccount"
@bind-value:event="oninput" placeholder="Search by AccountName"
@onchange="SearchAccount_OnChange"/>
</div>
@ -34,9 +34,9 @@ else
<th>@nameof(Account.AccountId)</th>
<th>@nameof(Account.AccountName)</th>
<th>@nameof(Account.Street)</th>
<th>@nameof(Account.ZIP)</th>
<th>@nameof(Account.Zip)</th>
<th>@nameof(Account.City)</th>
<th>@nameof(Account.SAPAccountNumber)</th>
<th>@nameof(Account.SapAccountNumber)</th>
</tr>
</thead>
<tbody>
@ -45,9 +45,9 @@ else
<td>@account.AccountId</td>
<td>@account.AccountName</td>
<td>@account.Street</td>
<td>@account.ZIP</td>
<td>@account.Zip</td>
<td>@account.City</td>
<td>@account.SAPAccountNumber</td>
<td>@account.SapAccountNumber</td>
<td>
<a class="nav-link" href="Accounts/Edit/@account.AccountId">
<span class="oi oi-pencil" aria-hidden="true">Edit</span>
@ -65,18 +65,18 @@ else
@code {
public string searchAccount = "";
public string SearchAccount = "";
List<Account> allAccounts = new();
List<Account> filteredAccounts = new();
protected override async Task OnInitializedAsync()
{
allAccounts = await Task.Run(() => accountService.GetAllAccountsAsync());
allAccounts = await Task.Run(() => AccountService.GetAllAccountsAsync());
filteredAccounts = allAccounts;
}
private void SearchAccount_OnChange()
{
filteredAccounts = allAccounts.Where(a => a.AccountName.ToLower().Contains(searchAccount.ToLower())).ToList();
filteredAccounts = allAccounts.Where(a => a.AccountName.ToLower().Contains(SearchAccount.ToLower())).ToList();
}
}

@ -3,9 +3,9 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject ContactService contactService
@inject NavigationManager navigationManager
@inject AccountService accountService
@inject ContactService ContactService
@inject NavigationManager NavigationManager
@inject AccountService AccountService
<h2>Add Contact</h2>
<hr />
@ -39,7 +39,7 @@
</div>
<div class="form-group">
<label for="SAPContactNumber" class="control-label">SAPContactNumber</label>
<input form="SAPContactNumber" class="form-control" @bind="@contact.SAPContactNumber" />
<input form="SAPContactNumber" class="form-control" @bind="@contact.SapContactNumber" />
</div>
</div>
</div>
@ -62,11 +62,11 @@
contact.DataModificationByUser = "Gremlin_BlazorServer";
//contact.DataStatus = "Active";
if (await contactService.InsertContactAsync(contact))
if (await ContactService.InsertContactAsync(contact))
{
navigationManager.NavigateTo("Contacts/Index");
NavigationManager.NavigateTo("Contacts/Index");
}
}
void Cancel() => navigationManager.NavigateTo("Contacts/Index");
void Cancel() => NavigationManager.NavigateTo("Contacts/Index");
}

@ -3,8 +3,8 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject ContactService contactService
@inject NavigationManager navigationManager
@inject ContactService ContactService
@inject NavigationManager NavigationManager
<h2>Delete Employee</h2>
<hr />
@ -38,7 +38,7 @@
</div>
<div class="form-group">
<label>SAPContactNumber:</label>
<label>@contact.SAPContactNumber</label>
<label>@contact.SapContactNumber</label>
</div>
</div>
@ -55,20 +55,20 @@
@code {
[Parameter]
public string contactId { get; set; } = default!;
public string ContactId { get; set; } = default!;
Contact contact = new Contact();
protected override async Task OnInitializedAsync()
{
contact = await Task.Run(() => contactService.GetContactAsync(Convert.ToUInt32(contactId)));
contact = await Task.Run(() => ContactService.GetContactAsync(Convert.ToUInt32(ContactId)));
}
protected async void DeleteContact()
{
await contactService.DeleteContactAsync(contact);
navigationManager.NavigateTo("Contacts/Index");
await ContactService.DeleteContactAsync(contact);
NavigationManager.NavigateTo("Contacts/Index");
}
void Cancel()
{
navigationManager.NavigateTo("Contacts/Index");
NavigationManager.NavigateTo("Contacts/Index");
}
}

@ -3,8 +3,8 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject ContactService contactService
@inject NavigationManager navigationManager
@inject ContactService ContactService
@inject NavigationManager NavigationManager
<h2>Edit Contact</h2>
<hr />
@ -38,7 +38,7 @@
</div>
<div class="form-group">
<label for="SAPContactNumber" class="control-label">SAPContactNumber</label>
<input form="SAPContactNumber" class="form-control" @bind="@contact.SAPContactNumber" />
<input form="SAPContactNumber" class="form-control" @bind="@contact.SapContactNumber" />
</div>
</div>
</div>
@ -55,12 +55,12 @@
@code {
[Parameter]
public string contactId { get; set; } = string.Empty;
public string ContactId { get; set; } = string.Empty;
Contact contact = new Contact();
protected override async Task OnInitializedAsync()
{
contact = await Task.Run(() => contactService.GetContactAsync(Convert.ToUInt32(contactId)));
contact = await Task.Run(() => ContactService.GetContactAsync(Convert.ToUInt32(ContactId)));
}
protected async void UpdateContact()
@ -68,9 +68,9 @@
contact.DataModificationByUser = "Gremlin_BlazorServer";
contact.DataModificationDate = DateTime.Now;
contact.DataVersionNumber++;
await contactService.UpdateContactAsync(contact);
navigationManager.NavigateTo("Contacts/Index");
await ContactService.UpdateContactAsync(contact);
NavigationManager.NavigateTo("Contacts/Index");
}
void Cancel() => navigationManager.NavigateTo("Contacts/Index");
void Cancel() => NavigationManager.NavigateTo("Contacts/Index");
}

@ -3,7 +3,7 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject ContactService contactService
@inject ContactService ContactService
<h1>Contacts</h1>
@ -15,7 +15,7 @@
<DataGridColumn Field="@nameof(Contact.FirstName)" Caption="FirstName" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Contact.Gender)" Caption="Gender" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Contact.EMail)" Caption="EMail" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Contact.SAPContactNumber)" Caption="SAPContactNumber" Filterable Sortable Editable/>
<DataGridColumn Field="@nameof(Contact.SapContactNumber)" Caption="SAPContactNumber" Filterable Sortable Editable/>
</DataGrid>
<Column ColumnSize="ColumnSize.Is4">
@ -24,7 +24,7 @@
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">LastName</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedContact.LastName"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">AccountName</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedContact.Account.AccountName"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">AccountStreet</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedContact.Account.Street"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">AccountZIP</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedContact.Account.ZIP.ToString()"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">AccountZIP</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedContact.Account.Zip.ToString()"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">AccountCity</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedContact.Account.City"/></FieldBody></Field>
</Fields>
</Column>
@ -35,7 +35,7 @@
protected override async Task OnInitializedAsync()
{
contacts = await Task.Run(() => contactService.GetAllContactsAsync());
contacts = await Task.Run(() => ContactService.GetAllContactsAsync());
selectedContact = contacts[0];
}

@ -3,8 +3,8 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject CustomDescriptionService customDescriptionService
@inject NavigationManager navigationManager
@inject CustomDescriptionService CustomDescriptionService
@inject NavigationManager NavigationManager
<h2>Add CustomDescription</h2>
<hr />
@ -52,11 +52,11 @@
{
customDescription.DataModificationByUser = "Gremlin_BlazorServer";
if (await customDescriptionService.InsertCustomDescriptionAsync(customDescription))
if (await CustomDescriptionService.InsertCustomDescriptionAsync(customDescription))
{
navigationManager.NavigateTo("CustomDescriptions/Index");
NavigationManager.NavigateTo("CustomDescriptions/Index");
}
}
void Cancel() => navigationManager.NavigateTo("CustomDescriptions/Index");
void Cancel() => NavigationManager.NavigateTo("CustomDescriptions/Index");
}

@ -3,8 +3,8 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject CustomDescriptionService customDescriptionService
@inject NavigationManager navigationManager
@inject CustomDescriptionService CustomDescriptionService
@inject NavigationManager NavigationManager
<h2>Delete Employee</h2>
<hr />
@ -47,20 +47,20 @@
@code {
[Parameter]
public string customDescriptionId { get; set; } = string.Empty;
public string CustomDescriptionId { get; set; } = string.Empty;
CustomDescription customDescription = new CustomDescription();
protected override async Task OnInitializedAsync()
{
customDescription = await Task.Run(() => customDescriptionService.GetCustomDescriptionAsync(Convert.ToUInt32(customDescriptionId)));
customDescription = await Task.Run(() => CustomDescriptionService.GetCustomDescriptionAsync(Convert.ToUInt32(CustomDescriptionId)));
}
protected async void DeleteCustomDescription()
{
await customDescriptionService.DeleteCustomDescriptionAsync(customDescription);
navigationManager.NavigateTo("CustomDescriptions/Index");
await CustomDescriptionService.DeleteCustomDescriptionAsync(customDescription);
NavigationManager.NavigateTo("CustomDescriptions/Index");
}
void Cancel()
{
navigationManager.NavigateTo("CustomDescriptions/Index");
NavigationManager.NavigateTo("CustomDescriptions/Index");
}
}

@ -3,8 +3,8 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject CustomDescriptionService customDescriptionservice
@inject NavigationManager navigationManager
@inject CustomDescriptionService CustomDescriptionservice
@inject NavigationManager NavigationManager
<h2>Edit CustomDescription</h2>
<hr />
@ -47,12 +47,12 @@
@code {
[Parameter]
public string? customDescriptionId { get; set; }
public string? CustomDescriptionId { get; set; }
CustomDescription customDescription = new CustomDescription();
protected override async Task OnInitializedAsync()
{
customDescription = await Task.Run(() => customDescriptionservice.GetCustomDescriptionAsync(Convert.ToUInt32(customDescriptionId)));
customDescription = await Task.Run(() => CustomDescriptionservice.GetCustomDescriptionAsync(Convert.ToUInt32(CustomDescriptionId)));
}
protected async void UpdateCustomDescription()
@ -60,9 +60,9 @@
customDescription.DataModificationByUser = "Gremlin_BlazorServer";
customDescription.DataModificationDate = DateTime.Now;
customDescription.DataVersionNumber++;
await customDescriptionservice.UpdateCustomDescriptionAsync(customDescription);
navigationManager.NavigateTo("CustomDescriptions/Index");
await CustomDescriptionservice.UpdateCustomDescriptionAsync(customDescription);
NavigationManager.NavigateTo("CustomDescriptions/Index");
}
void Cancel() => navigationManager.NavigateTo("CustomDescriptions/Index");
void Cancel() => NavigationManager.NavigateTo("CustomDescriptions/Index");
}

@ -3,13 +3,13 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject CustomDescriptionService customDescriptionservice
@inject CustomDescriptionService CustomDescriptionservice
<h1>CustomDescriptions</h1>
<div class="text-center bg-blue-100">
<input class="border-4 w-1/3 rounded m-6 p-6 h-8
border-blue-300" @bind-value="searchCustomDescription"
border-blue-300" @bind-value="SearchCustomDescription"
@bind-value:event="oninput" placeholder="Search by ProductNumber"
@onchange="SearchCustomDescription_OnChange"/>
</div>
@ -62,18 +62,18 @@ else
@code {
public string searchCustomDescription = "";
public string SearchCustomDescription = "";
List<CustomDescription> allCustomDescriptions = new();
List<CustomDescription> filteredCustomDescriptions = new();
protected override async Task OnInitializedAsync()
{
allCustomDescriptions = await Task.Run(() => customDescriptionservice.GetAllCustomDescriptionsAsync());
allCustomDescriptions = await Task.Run(() => CustomDescriptionservice.GetAllCustomDescriptionsAsync());
filteredCustomDescriptions = allCustomDescriptions;
}
private void SearchCustomDescription_OnChange()
{
filteredCustomDescriptions = allCustomDescriptions.Where(cD => cD.ProductNumber.ToLower().Contains(searchCustomDescription.ToLower())).ToList();
filteredCustomDescriptions = allCustomDescriptions.Where(cD => cD.ProductNumber.ToLower().Contains(SearchCustomDescription.ToLower())).ToList();
}
}

@ -2,7 +2,7 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject LoginService loginService
@inject LoginService LoginService
<PageTitle>Gremlin BlazorServer</PageTitle>
@ -22,7 +22,7 @@
</CascadingAuthenticationState>
@code {
private RegisteredUser registeredUser = new();
private readonly RegisteredUser registeredUser = new();
private bool IsAuthenticated { get; set; }
//protected async override Task OnInitializedAsync()

@ -4,13 +4,13 @@
@using Gremlin_BlazorServer.Services;
@using System.Globalization;
@inject LineItemService lineItemservice
@inject LineItemService LineItemservice
<h1>LineItems</h1>
<div class="text-center bg-blue-100">
<input class="border-4 w-1/3 rounded m-6 p-6 h-8
border-blue-300" @bind-value="searchLineItem"
border-blue-300" @bind-value="SearchLineItem"
@bind-value:event="oninput" placeholder="Search by ProductNumber"
@onchange="SearchLineItem_OnChange"/>
</div>
@ -53,32 +53,32 @@ else
</tr>
</thead>
<tbody>
@foreach (LineItem LineItem in filteredLineItems)
@foreach (LineItem lineItem in filteredLineItems)
{<tr>
<td>@LineItem.LineItemId</td>
<td>@LineItem.QuoteId</td>
<td>@LineItem.Position</td>
<td>@LineItem.Amount</td>
<td>@LineItem.ProductNumber</td>
<td>@LineItem.OptionNumber</td>
<td>@LineItem.SapShortDescription</td>
<td>@LineItem.SapLongDescription</td>
<td>@LineItem.ProductLine</td>
<td>@LineItem.TotalDiscount</td>
<td>@LineItem.SalesDiscount</td>
<td>@LineItem.SalesDiscount</td>
<td>@LineItem.PromotionalDiscount</td>
<td>@LineItem.ContractualDiscount</td>
<td>@LineItem.DemoDiscount</td>
<td>@LineItem.ListPrice.ToString("C", cultureInfo)</td>
<td>@LineItem.ExtendedListPrice.ToString("C", cultureInfo)</td>
<td>@LineItem.NetPrice.ToString("C", cultureInfo)</td>
<td>@LineItem.Total.ToString("C", cultureInfo)</td>
<td>@lineItem.LineItemId</td>
<td>@lineItem.QuoteId</td>
<td>@lineItem.Position</td>
<td>@lineItem.Amount</td>
<td>@lineItem.ProductNumber</td>
<td>@lineItem.OptionNumber</td>
<td>@lineItem.SapShortDescription</td>
<td>@lineItem.SapLongDescription</td>
<td>@lineItem.ProductLine</td>
<td>@lineItem.TotalDiscount</td>
<td>@lineItem.SalesDiscount</td>
<td>@lineItem.SalesDiscount</td>
<td>@lineItem.PromotionalDiscount</td>
<td>@lineItem.ContractualDiscount</td>
<td>@lineItem.DemoDiscount</td>
<td>@lineItem.ListPrice.ToString("C", cultureInfo)</td>
<td>@lineItem.ExtendedListPrice.ToString("C", cultureInfo)</td>
<td>@lineItem.NetPrice.ToString("C", cultureInfo)</td>
<td>@lineItem.Total.ToString("C", cultureInfo)</td>
<td>
<a class="nav-link" href="LineItems/Edit/@LineItem.LineItemId">
<a class="nav-link" href="LineItems/Edit/@lineItem.LineItemId">
<span class="oi oi-pencil" aria-hidden="true">Edit</span>
</a>
<a class="nav-link" href="LineItems/Delete/@LineItem.LineItemId">
<a class="nav-link" href="LineItems/Delete/@lineItem.LineItemId">
<span class="oi oi-trash" aria-hidden="true">Delete</span>
</a>
</td>
@ -90,19 +90,19 @@ else
@code {
public string searchLineItem = "";
public string SearchLineItem = "";
List<LineItem> allLineItems = new();
List<LineItem> filteredLineItems = new();
CultureInfo cultureInfo = new("de-DE");
protected override async Task OnInitializedAsync()
{
allLineItems = await Task.Run(() => lineItemservice.GetLineItemsAsync());
allLineItems = await Task.Run(() => LineItemservice.GetLineItemsAsync());
filteredLineItems = allLineItems;
}
private void SearchLineItem_OnChange()
{
filteredLineItems = allLineItems.Where(cD => cD.ProductNumber!.ToLower().Contains(searchLineItem.ToLower())).ToList();
filteredLineItems = allLineItems.Where(cD => cD.ProductNumber!.ToLower().Contains(SearchLineItem.ToLower())).ToList();
}
}

@ -3,7 +3,7 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@inject LoginService loginService
@inject LoginService LoginService
<h3>Login</h3>
@ -95,12 +95,12 @@
Validations loginValidationsRef = new();
Validations registerValidationsRef = new();
private RegisteredUser registeredUser = new();
private readonly RegisteredUser registeredUser = new();
private string selectedTab = "login";
private string userName = "";
private string password = "";
private bool rememberMe = false;
private bool rememberMe;
private Task OnSelectedTabChanged(string name)
{
@ -119,7 +119,7 @@
PasswordHash = password
};
bool IsValidated = await Task.Run(() => loginService.ValidateUserAsync(registeredUser));
await Task.Run(() => LoginService.ValidateUserAsync(registeredUser));
await loginValidationsRef.ClearAll();
}
}
@ -131,7 +131,7 @@
registeredUser.UserName = userName;
registeredUser.PasswordHash = password;
_ = await Task.Run(() => loginService.InsertRegisteredUserAsync(registeredUser));
_ = await Task.Run(() => LoginService.InsertRegisteredUserAsync(registeredUser));
await registerValidationsRef.ClearAll();
}

@ -5,7 +5,7 @@
@using System.Globalization;
@using System.Diagnostics;
@inject ProductLineService productLineService
@inject ProductLineService ProductLineService
<h1>ProductLines</h1>
@ -38,7 +38,7 @@ else
}
@code {
public string searchProductLine = "";
public string SearchProductLine = "";
CultureInfo cultureInfo = new("de-DE");
ProductLine selectedProductLine = new();
@ -46,7 +46,7 @@ else
protected override async Task OnParametersSetAsync()
{
productLines = await Task.Run(() => productLineService.GetAllProductLinesAsync());
productLines = await Task.Run(() => ProductLineService.GetAllProductLinesAsync());
selectedProductLine = productLines.FirstOrDefault()!;
}
}

@ -5,7 +5,7 @@
@using System.Globalization;
@using System.Diagnostics;
@inject ProductService productService
@inject ProductService ProductService
<h1>Products</h1>
@ -43,7 +43,7 @@ else
}
@code {
public string searchProduct = "";
public string SearchProduct = "";
CultureInfo cultureInfo = new("de-DE");
Product selectedProduct = new();
@ -51,7 +51,7 @@ else
protected override async Task OnParametersSetAsync()
{
products = await Task.Run(() => productService.GetAllProductsAsync());
products = await Task.Run(() => ProductService.GetAllProductsAsync());
selectedProduct = products.FirstOrDefault()!;
}

@ -7,12 +7,12 @@
@using System.Text;
@using System.Globalization;
@inject QuoteService quoteService
@inject ContactService contactService
@inject AccountService accountService
@inject NavigationManager navigationManager
@inject ClipboardService clipboardService
@inject IJSRuntime JSRuntime
@inject QuoteService QuoteService
@inject ContactService ContactService
@inject AccountService AccountService
@inject NavigationManager NavigationManager
@inject ClipboardService ClipboardService
@inject IJSRuntime JsRuntime
<h1>Create New Quote</h1>
<hr />
@ -27,7 +27,7 @@
<DataGridColumn Field="@nameof(Contact.Gender)" Caption="Gender" Sortable Filterable/>
<DataGridColumn Field="@nameof(Contact.EMail)" Caption="EMail" Sortable Filterable/>
<DataGridColumn Field="@nameof(Contact.PhoneNumber)" Caption="PhoneNumber" Sortable Filterable />
<DataGridColumn Field="@nameof(Contact.SAPContactNumber)" Caption="SAPContactNumber" Sortable Filterable />
<DataGridColumn Field="@nameof(Contact.SapContactNumber)" Caption="SAPContactNumber" Sortable Filterable />
</DataGrid>
<Divider DividerType="DividerType.TextContent" Text="Quote Details"/>
@ -40,7 +40,7 @@
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Angebotspfad:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6">@quote.Path</FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Gewährleistung (Monate):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6">@quote.Warranty</FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Angebotsgültigkeit (Tage):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit Text="@quote.ValidFor.ToString()" TextChanged="@OnValidForChanged" /></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Mehrwertsteuer (%):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit Text="@quote.VAT.ToString()" TextChanged="@OnVATChanged" /></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Mehrwertsteuer (%):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit Text="@quote.Vat.ToString()" TextChanged="@OnVATChanged" /></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Versandkosten (%):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit Text="@quote.Freight.ToString()" /></FieldBody></Field>
</Fields>
</Column>
@ -57,7 +57,7 @@
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Summe netto:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@quote.TotalNet.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Versandkosten:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@quote.TotalFreightOnly.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Gesamtsumme netto:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@quote.TotalFreight.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Mehrwertsteuer:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@quote.TotalVAT.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Mehrwertsteuer:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@quote.TotalVat.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Gesamtsumme brutto:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@quote.TotalGross.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
</Column>
@ -99,11 +99,11 @@
protected override async Task OnInitializedAsync()
{
contacts = await contactService.GetAllContactsAsync();
contacts = await ContactService.GetAllContactsAsync();
await OnSelectedRowChanged(contacts.FirstOrDefault() ?? new());
Contact salesRep = await contactService.GetContactAsync("Woitschetzki");
quote = new(salesRep, true);
Contact salesRep = await ContactService.GetContactAsync("Woitschetzki");
quote = new(salesRep);
quote.Description = "HPLC";
await base.OnInitializedAsync();
@ -115,23 +115,19 @@
{
foreach (var file in e.Files)
{
using (MemoryStream stream = new())
{
await file.WriteToStreamAsync(stream);
stream.Seek(0, SeekOrigin.Begin);
using (StreamReader reader = new(stream))
{
string fileContent = await reader.ReadToEndAsync();
quote = quoteService.ReadLineItems(quote, fileContent);
quote.Path = $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Quotes{Path.DirectorySeparatorChar}{quote.Recipient.Account.AccountName}{Path.DirectorySeparatorChar}{DateTime.Today.Year}-{quote.Recipient.LastName}-{quote.Description}";
FileService.WriteClipboardToTSV(fileContent, quote);
}
}
using MemoryStream stream = new();
await file.WriteToStreamAsync(stream);
stream.Seek(0, SeekOrigin.Begin);
using StreamReader reader = new(stream);
string fileContent = await reader.ReadToEndAsync();
quote = QuoteService.ReadLineItems(quote, fileContent);
quote.Path = $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Quotes{Path.DirectorySeparatorChar}{quote.Recipient.Account.AccountName}{Path.DirectorySeparatorChar}{DateTime.Today.Year}-{quote.Recipient.LastName}-{quote.Description}";
FileService.WriteClipboardToTsv(fileContent, quote);
}
}
catch (Exception exc) { Console.WriteLine(exc.Message); }
finally { this.StateHasChanged(); }
finally { StateHasChanged(); }
}
private void SelectQuoteOnWritten(FileWrittenEventArgs e) => Console.WriteLine($"File: {e.File.Name} Position: {e.Position} Data: {Convert.ToBase64String(e.Data)}");
@ -142,28 +138,28 @@
{
selectedRecipient = contact;
quote.Recipient = contact;
correspondingAccount = await accountService.GetAccountAsync(contact.AccountId) ?? new Account();
correspondingAccount = await AccountService.GetAccountAsync(contact.AccountId) ?? new Account();
}
protected async void OnSave()
{
quote.DataModificationByUser = "Gremlin_BlazorServer";
if (await quoteService.InsertQuoteAsync(quote))
if (await QuoteService.InsertQuoteAsync(quote))
{
navigationManager.NavigateTo("Quotes/Index");
NavigationManager.NavigateTo("Quotes/Index");
}
}
protected async void OnCreateTex()
{
StringBuilder texStringBuilder = await quoteService.CreateTex(quote);
StringBuilder texStringBuilder = await QuoteService.CreateTex(quote);
quote.Tex = texStringBuilder.ToString();
FileService.WriteTexFile(quote);
}
protected void OnCreatePdf() => PdfService.CreatePDF(quote);
protected void OnCreatePdf() => PdfService.CreatePdf(quote);
protected void OnOpenPdf() => PdfService.OpenPDF(quote);
protected void OnOpenPdf() => PdfService.OpenPdf(quote);
private Task OnDescriptionChanged(string value)
{
@ -185,7 +181,7 @@
private Task OnVATChanged(string value)
{
quote.VAT = float.Parse(value);
quote.Vat = float.Parse(value);
return Task.CompletedTask;
}
@ -213,5 +209,5 @@
return Task.CompletedTask;
}
void OnCancel() => navigationManager.NavigateTo("Quotes/Index");
void OnCancel() => NavigationManager.NavigateTo("Quotes/Index");
}

@ -3,9 +3,8 @@
@using Gremlin_BlazorServer.Data.EntityClasses;
@using Gremlin_BlazorServer.Services;
@using System.Globalization;
@using System.Diagnostics;
@inject QuoteService quoteService
@inject QuoteService QuoteService
<Divider DividerType="DividerType.TextContent" Text="Quotes"/>
<NavLink class="nav-link" href="Quotes/Add">
@ -20,8 +19,8 @@
<DataGridColumn Field="@nameof(Quote.ValidUntil)" Caption="ValidUntil" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.TotalNet)" Caption="TotalNet" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.TotalGross)" Caption="TotalGross" DisplayFormat="{0:C}" DisplayFormatProvider=cultureInfo Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuoteContains3PP)" Caption="3PP" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuoteContainsRB)" Caption="RB" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuoteContains3Pp)" Caption="3PP" Filterable Sortable/>
<DataGridColumn Field="@nameof(Quote.QuoteContainsRb)" Caption="RB" Filterable Sortable/>
</DataGrid>
<Divider DividerType="DividerType.TextContent" Text="Quote Details"/>
@ -34,8 +33,8 @@
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Angebotspfad:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6">@selectedQuote.Path</FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Gewährleistung (Monate):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6">@selectedQuote.Warranty</FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Angebotsgültigkeit (Tage):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit Text="@selectedQuote.ValidFor.ToString()"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Mehrwertsteuer (%):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit Text="@selectedQuote.VAT.ToString()"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Versandkosten (%):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit Text="@selectedQuote.Freight.ToString()" /></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Mehrwertsteuer (%):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit Text="@selectedQuote.Vat.ToString(CultureInfo.CurrentCulture)"/></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Versandkosten (%):</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit Text="@selectedQuote.Freight.ToString(CultureInfo.CurrentCulture)" /></FieldBody></Field>
</Fields>
</Column>
@ -57,7 +56,7 @@
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Summe netto:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedQuote.TotalNet.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Versandkosten:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedQuote.TotalFreightOnly.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Gesamtsumme netto:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedQuote.TotalFreight.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Mehrwertsteuer:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedQuote.TotalVAT.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Mehrwertsteuer:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedQuote.TotalVat.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
<Field Horizontal><FieldLabel ColumnSize="ColumnSize.Is4">Gesamtsumme brutto:</FieldLabel><FieldBody ColumnSize="ColumnSize.Is6"><TextEdit ReadOnly Text="@selectedQuote.TotalGross.ToString("C", CultureInfo.CurrentCulture)"></TextEdit></FieldBody></Field>
</Column>
@ -84,8 +83,8 @@
</DataGrid>
@code {
public string searchQuote = "";
CultureInfo cultureInfo = new("de-DE");
public string SearchQuote = "";
readonly CultureInfo cultureInfo = new("de-DE");
Quote selectedQuote = new();
List<LineItem> lineItemsInSelectedQuote = new();
@ -94,15 +93,15 @@
protected override async Task OnInitializedAsync()
{
quotes = await Task.Run(() => quoteService.GetAllQuotesAsync());
quotes = await Task.Run(() => QuoteService.GetAllQuotesAsync());
await OnSelectedQuoteChanged(quotes.LastOrDefault() ?? new());
await base.OnInitializedAsync();
}
private async Task OnSelectedQuoteChanged(Quote selectedQuote)
private async Task OnSelectedQuoteChanged(Quote _selectedQuote)
{
lineItemsInSelectedQuote = await quoteService.GetLineItemsAsync(selectedQuote);
this.selectedQuote = selectedQuote;
lineItemsInSelectedQuote = await QuoteService.GetLineItemsAsync(_selectedQuote);
this.selectedQuote = _selectedQuote;
}
}

@ -31,19 +31,19 @@ namespace Gremlin_BlazorServer.Services
public async Task<AccountType?> GetAccountTypeAsync(string accountTypeCode)
{
return await gremlinContext.AccountTypes.FirstOrDefaultAsync(AccountType => AccountType.AccountTypeCode.Equals(accountTypeCode));
return await gremlinContext.AccountTypes.FirstOrDefaultAsync(accountType => accountType.AccountTypeCode.Equals(accountTypeCode));
}
public async Task<bool> UpdateAccountTypeAsync(AccountType AccountType)
public async Task<bool> UpdateAccountTypeAsync(AccountType accountType)
{
_ = gremlinContext.AccountTypes.Update(AccountType);
_ = gremlinContext.AccountTypes.Update(accountType);
_ = await gremlinContext.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteAccountTypeAsync(AccountType AccountType)
public async Task<bool> DeleteAccountTypeAsync(AccountType accountType)
{
_ = gremlinContext.Remove(AccountType);
_ = gremlinContext.Remove(accountType);
_ = await gremlinContext.SaveChangesAsync();
return true;
}

@ -1,25 +1,24 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.EntityFrameworkCore;
using Microsoft.VisualStudio.Web.CodeGenerators.Mvc.Controller;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
public class ContactService
{
private static GremlinContext gremlinContext = new();
private readonly AccountService accountService = new(gremlinContext);
private readonly AccountTypeService accountTypeService = new(gremlinContext);
private static GremlinContext _gremlinContext = new();
private readonly AccountService accountService = new(_gremlinContext);
private readonly AccountTypeService accountTypeService = new(_gremlinContext);
public ContactService(GremlinContext gC) => gremlinContext = gC;
public ContactService(GremlinContext gC) => _gremlinContext = gC;
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinContext>(ServiceLifetime.Scoped);
}
public async Task<List<Contact>> GetAllContactsAsync() => await gremlinContext.Contacts.Include(c => c.Account).ToListAsync();
public async Task<List<Contact>> GetAllContactsAsync() => await _gremlinContext.Contacts.Include(c => c.Account).ToListAsync();
public async Task<bool> InsertContactAsync(Contact contact)
{
@ -27,8 +26,8 @@ namespace Gremlin_BlazorServer.Services
contact.Account.AccountType = await accountTypeService.GetAccountTypeAsync("FPC") ?? new AccountType();
try
{
_ = await gremlinContext.Contacts.AddAsync(contact);
_ = await gremlinContext.SaveChangesAsync();
_ = await _gremlinContext.Contacts.AddAsync(contact);
_ = await _gremlinContext.SaveChangesAsync();
return true;
}
catch (Exception exception)
@ -40,27 +39,27 @@ namespace Gremlin_BlazorServer.Services
public async Task<Contact> GetContactAsync(uint contactId)
{
Contact? contact = await gremlinContext.Contacts.FirstOrDefaultAsync(c => c.ContactId.Equals(contactId));
Contact? contact = await _gremlinContext.Contacts.FirstOrDefaultAsync(c => c.ContactId.Equals(contactId));
return contact ?? new Contact();
}
public async Task<Contact> GetContactAsync(string lastName)
{
Contact? contact = await gremlinContext.Contacts.FirstOrDefaultAsync(c => c.LastName.Equals(lastName));
Contact? contact = await _gremlinContext.Contacts.FirstOrDefaultAsync(c => c.LastName.Equals(lastName));
return contact ?? new Contact();
}
public async Task<bool> UpdateContactAsync(Contact contact)
{
_ = gremlinContext.Contacts.Update(contact);
_ = await gremlinContext.SaveChangesAsync();
_ = _gremlinContext.Contacts.Update(contact);
_ = await _gremlinContext.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteContactAsync(Contact contact)
{
_ = gremlinContext.Remove(contact);
_ = await gremlinContext.SaveChangesAsync();
_ = _gremlinContext.Remove(contact);
_ = await _gremlinContext.SaveChangesAsync();
return true;
}
}

@ -1,6 +1,5 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;

@ -20,14 +20,11 @@ namespace Gremlin_BlazorServer.Services
? name
: assembly.GetManifestResourceNames().Single(str => str.EndsWith(name));
using (Stream? stream = assembly.GetManifestResourceStream(resourcePath))
{
if (stream == null) { return ""; }
using (StreamReader reader = new(stream))
{
return reader.ReadToEnd();
}
}
using Stream? stream = assembly.GetManifestResourceStream(resourcePath);
if (stream == null) { return ""; }
using StreamReader reader = new(stream);
return reader.ReadToEnd();
}
// public static string GetFilepathFromUser(string filter = "Delimited Data File|*.csv; *.txt; *.tsv")
@ -62,15 +59,13 @@ namespace Gremlin_BlazorServer.Services
public static Encoding GetEncoding(string fileName)
{
Stream fileStream = File.OpenRead(fileName);
using (StreamReader reader = new(fileStream, defaultEncodingIfNoBom, true))
{
_ = reader.Peek();
Encoding encoding = reader.CurrentEncoding;
return encoding;
}
using StreamReader reader = new(fileStream, defaultEncodingIfNoBom, true);
_ = reader.Peek();
Encoding encoding = reader.CurrentEncoding;
return encoding;
}
public static void WriteClipboardToTSV(string clipboard, Quote quote)
public static void WriteClipboardToTsv(string clipboard, Quote quote)
{
string datei = $"{quote.Path}{Path.DirectorySeparatorChar}{quote.QuotationNumber}.tsv";
FileInfo fileInfo = new(datei);

@ -35,19 +35,19 @@ namespace Gremlin_BlazorServer.Services
public async Task<LineItem?> GetLineItemAsync(uint lineItemId)
{
return await gremlinContext.LineItems.FirstOrDefaultAsync(LineItem => LineItem.LineItemId.Equals(lineItemId));
return await gremlinContext.LineItems.FirstOrDefaultAsync(lineItem => lineItem.LineItemId.Equals(lineItemId));
}
public async Task<bool> UpdateLineItemAsync(LineItem LineItem)
public async Task<bool> UpdateLineItemAsync(LineItem lineItem)
{
_ = gremlinContext.LineItems.Update(LineItem);
_ = gremlinContext.LineItems.Update(lineItem);
_ = await gremlinContext.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteLineItemAsync(LineItem LineItem)
public async Task<bool> DeleteLineItemAsync(LineItem lineItem)
{
_ = gremlinContext.Remove(LineItem);
_ = gremlinContext.Remove(lineItem);
_ = await gremlinContext.SaveChangesAsync();
return true;
}

@ -4,62 +4,61 @@ using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
public class LoginService
{
private readonly GremlinContext gremlinContext;
namespace Gremlin_BlazorServer.Services;
public LoginService(GremlinContext gC) => gremlinContext = gC;
private Task<AuthenticationState> AuthenticationStateTask { get; set; } = default!;
public class LoginService
{
private readonly GremlinContext gremlinContext;
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinContext>(ServiceLifetime.Scoped);
}
public LoginService(GremlinContext gC) => gremlinContext = gC;
public async Task<List<RegisteredUser>> GetAllRegisteredUserAsync() => await gremlinContext.RegisteredUser.ToListAsync();
private Task<AuthenticationState> AuthenticationStateTask { get; set; } = default!;
public async Task<bool> InsertRegisteredUserAsync(RegisteredUser registeredUser)
{
try
{
_ = await gremlinContext.RegisteredUser.AddAsync(registeredUser);
_ = await gremlinContext.SaveChangesAsync();
return true;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
return false;
}
}
public void ConfigureServices(IServiceCollection services)
{
_ = services.AddDbContext<GremlinContext>(ServiceLifetime.Scoped);
}
public async Task<RegisteredUser?> GetRegisteredUserAsync(string registeredUserName)
{
return await gremlinContext.RegisteredUser.FirstOrDefaultAsync(rU => rU.UserName.Equals(registeredUserName)!);
}
public async Task<List<RegisteredUser>> GetAllRegisteredUserAsync() => await gremlinContext.RegisteredUser.ToListAsync();
public async Task<bool> UpdateRegisteredUserAsync(RegisteredUser registeredUser)
public async Task<bool> InsertRegisteredUserAsync(RegisteredUser registeredUser)
{
try
{
_ = gremlinContext.RegisteredUser.Update(registeredUser);
_ = await gremlinContext.RegisteredUser.AddAsync(registeredUser);
_ = await gremlinContext.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteRegisteredUserAsync(RegisteredUser registeredUser)
catch (Exception exception)
{
_ = gremlinContext.Remove(registeredUser);
_ = await gremlinContext.SaveChangesAsync();
return true;
Debug.WriteLine(exception.Message);
return false;
}
}
public async Task<bool> ValidateUserAsync(RegisteredUser registeredUser)
{
_ = await Task.Run(() => GetRegisteredUserAsync(registeredUser.UserName));
AuthenticationState authState = await AuthenticationStateTask;
return authState.User.Identity != null ? authState.User.Identity.IsAuthenticated : false;
}
private async Task<RegisteredUser?> GetRegisteredUserAsync(string registeredUserName)
{
return await gremlinContext.RegisteredUser.FirstOrDefaultAsync(rU => rU.UserName.Equals(registeredUserName));
}
public async Task<bool> UpdateRegisteredUserAsync(RegisteredUser registeredUser)
{
_ = gremlinContext.RegisteredUser.Update(registeredUser);
_ = await gremlinContext.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteRegisteredUserAsync(RegisteredUser registeredUser)
{
_ = gremlinContext.Remove(registeredUser);
_ = await gremlinContext.SaveChangesAsync();
return true;
}
public async Task<bool> ValidateUserAsync(RegisteredUser registeredUser)
{
_ = await Task.Run(() => GetRegisteredUserAsync(registeredUser.UserName));
AuthenticationState authState = await AuthenticationStateTask;
return authState.User.Identity is { IsAuthenticated: true };
}
}

@ -3,12 +3,12 @@ using System.Diagnostics;
namespace Gremlin_BlazorServer.Services
{
internal class PdfService
internal abstract class PdfService
{
private static readonly string agilentLogo = $"Quotes{Path.DirectorySeparatorChar}agilentLogo.png";
private static readonly string signWoitschetzki = $"Quotes{Path.DirectorySeparatorChar}signWoitschetzki.png";
public static bool CreatePDF(Quote quote)
public static bool CreatePdf(Quote quote)
{
//Copy images to quotePath
try
@ -17,7 +17,7 @@ namespace Gremlin_BlazorServer.Services
File.Copy(signWoitschetzki, $"{quote.Path}{Path.DirectorySeparatorChar}signWoitschetzki.png");
//Create PDF twice
if (RunningPDFLaTeX(quote, 2))
if (RunningPdfLaTeX(quote, 2))
{
return RemoveTempFiles(quote.Path);
}
@ -34,7 +34,7 @@ namespace Gremlin_BlazorServer.Services
}
}
public static bool RemoveTempFiles(string quotePath)
private static bool RemoveTempFiles(string quotePath)
{
DirectoryInfo directoryInfo = new(quotePath);
foreach (FileInfo file in directoryInfo.EnumerateFiles())
@ -48,37 +48,33 @@ namespace Gremlin_BlazorServer.Services
return true;
}
private static bool RunningPDFLaTeX(Quote quote, int runs)
private static bool RunningPdfLaTeX(Quote quote, int runs)
{
for (int i = 0; i < runs; i++)
{
using (Process process = new())
{
process.StartInfo.WorkingDirectory = quote.Path;
process.StartInfo.FileName = "pdflatex";
process.StartInfo.Arguments = quote.QuotationNumber;
process.StartInfo.UseShellExecute = true;
using Process process = new();
process.StartInfo.WorkingDirectory = quote.Path;
process.StartInfo.FileName = "pdflatex";
process.StartInfo.Arguments = quote.QuotationNumber;
process.StartInfo.UseShellExecute = true;
try { process.Start(); }
catch (Exception ex) { Debug.WriteLine(ex); return false; }
try { process.Start(); }
catch (Exception ex) { Debug.WriteLine(ex); return false; }
process.WaitForExit();
}
process.WaitForExit();
}
return true;
}
public static bool OpenPDF(Quote quote)
public static bool OpenPdf(Quote quote)
{
using (Process process = new())
{
process.StartInfo.WorkingDirectory = quote.Path;
process.StartInfo.FileName = "okular"; //@"C:\Program Files\Okular\bin\okular.exe";
process.StartInfo.Arguments = $"{quote.QuotationNumber}.pdf";
using Process process = new();
process.StartInfo.WorkingDirectory = quote.Path;
process.StartInfo.FileName = "okular"; //@"C:\Program Files\Okular\bin\okular.exe";
process.StartInfo.Arguments = $"{quote.QuotationNumber}.pdf";
try { return process.Start(); }
catch (Exception ex) { Debug.WriteLine(ex); return false; }
}
try { return process.Start(); }
catch (Exception ex) { Debug.WriteLine(ex); return false; }
}
}
}

@ -31,19 +31,19 @@ namespace Gremlin_BlazorServer.Services
public async Task<ProductLine?> GetProductLineAsync(string productLineCode)
{
return await gremlinContext.ProductLines.FirstOrDefaultAsync(ProductLine => ProductLine.ProductLineCode.Equals(productLineCode));
return await gremlinContext.ProductLines.FirstOrDefaultAsync(productLine => productLine.ProductLineCode.Equals(productLineCode));
}
public async Task<bool> UpdateProductLineAsync(ProductLine ProductLine)
public async Task<bool> UpdateProductLineAsync(ProductLine productLine)
{
_ = gremlinContext.ProductLines.Update(ProductLine);
_ = gremlinContext.ProductLines.Update(productLine);
_ = await gremlinContext.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteProductLineAsync(ProductLine ProductLine)
public async Task<bool> DeleteProductLineAsync(ProductLine productLine)
{
_ = gremlinContext.Remove(ProductLine);
_ = gremlinContext.Remove(productLine);
_ = await gremlinContext.SaveChangesAsync();
return true;
}

@ -14,11 +14,11 @@ namespace Gremlin_BlazorServer.Services
public async Task<List<Product>> GetAllProductsAsync() => await gremlinContext.Products.ToListAsync();
public async Task<bool> InsertProductAsync(Product Product)
public async Task<bool> InsertProductAsync(Product product)
{
try
{
_ = await gremlinContext.Products.AddAsync(Product);
_ = await gremlinContext.Products.AddAsync(product);
_ = await gremlinContext.SaveChangesAsync();
return true;
}
@ -31,20 +31,20 @@ namespace Gremlin_BlazorServer.Services
public async Task<Product?> GetProductAsync(string productNumber)
{
Product? Product = await gremlinContext.Products.FirstOrDefaultAsync(Product => Product.ProductNumber.Equals(productNumber));
return Product;
Product? product = await gremlinContext.Products.FirstOrDefaultAsync(product => product.ProductNumber.Equals(productNumber));
return product;
}
public async Task<bool> UpdateProductAsync(Product Product)
public async Task<bool> UpdateProductAsync(Product product)
{
_ = gremlinContext.Products.Update(Product);
_ = gremlinContext.Products.Update(product);
_ = await gremlinContext.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteProductAsync(Product Product)
public async Task<bool> DeleteProductAsync(Product product)
{
_ = gremlinContext.Remove(Product);
_ = gremlinContext.Remove(product);
_ = await gremlinContext.SaveChangesAsync();
return true;
}

@ -9,23 +9,23 @@ namespace Gremlin_BlazorServer.Services
{
public class QuoteService
{
private static GremlinContext gremlinContext = new();
public QuoteService(GremlinContext gC) => gremlinContext = gC;
private static GremlinContext _gremlinContext = new();
public QuoteService(GremlinContext gC) => _gremlinContext = gC;
private readonly TexService texService = new(gremlinContext);
private readonly TexService texService = new(_gremlinContext);
public void ConfigureServices(IServiceCollection services) => services.AddDbContext<GremlinContext>(ServiceLifetime.Scoped);
public async Task<List<Quote>> GetAllQuotesAsync() => await gremlinContext.Quotes.ToListAsync();
public async Task<List<Quote>> GetAllQuotesAsync() => await _gremlinContext.Quotes.ToListAsync();
public async Task<List<LineItem>> GetLineItemsAsync(Quote quote) => await gremlinContext.LineItems.Where(lI => lI.QuoteId == quote.QuoteId).ToListAsync();
public async Task<List<LineItem>> GetLineItemsAsync(Quote quote) => await _gremlinContext.LineItems.Where(lI => lI.QuoteId == quote.QuoteId).ToListAsync();
public async Task<bool> InsertQuoteAsync(Quote quote)
{
try
{
_ = await gremlinContext.Quotes.AddAsync(quote);
_ = await gremlinContext.SaveChangesAsync();
_ = await _gremlinContext.Quotes.AddAsync(quote);
_ = await _gremlinContext.SaveChangesAsync();
return true;
}
catch (Exception exception)
@ -35,19 +35,19 @@ namespace Gremlin_BlazorServer.Services
}
}
public async Task<Quote> GetQuoteAsync(uint quoteId) => await gremlinContext.Quotes.FirstOrDefaultAsync(q => q.QuoteId.Equals(quoteId)) ?? new Quote();
public async Task<Quote> GetQuoteAsync(uint quoteId) => await _gremlinContext.Quotes.FirstOrDefaultAsync(q => q.QuoteId.Equals(quoteId)) ?? new Quote();
public async Task<bool> UpdateQuoteAsync(Quote Quote)
public async Task<bool> UpdateQuoteAsync(Quote quote)
{
_ = gremlinContext.Quotes.Update(Quote);
_ = await gremlinContext.SaveChangesAsync();
_ = _gremlinContext.Quotes.Update(quote);
_ = await _gremlinContext.SaveChangesAsync();
return true;
}
public async Task<bool> DeleteQuoteAsync(Quote Quote)
public async Task<bool> DeleteQuoteAsync(Quote quote)
{
_ = gremlinContext.Remove(Quote);
_ = await gremlinContext.SaveChangesAsync();
_ = _gremlinContext.Remove(quote);
_ = await _gremlinContext.SaveChangesAsync();
return true;
}
@ -55,10 +55,7 @@ namespace Gremlin_BlazorServer.Services
{
StringBuilder texString = await texService.CreateTexAsync(quote);
if (texString.Length > 0)
Debug.WriteLine("Creating TexFile succesfully.");
else
Debug.WriteLine("Error during TexFile creation!");
Debug.WriteLine(texString.Length > 0 ? "Creating TexFile succesfully." : "Error during TexFile creation!");
return texString;
}
@ -73,8 +70,8 @@ namespace Gremlin_BlazorServer.Services
quote.LineItems = ReadLineItemsFromClipboard(clipboard);
quote.QuoteContains3PP = DoesContains(quote, "3PP");
quote.QuoteContainsRB = DoesContains(quote, "RB");
quote.QuoteContains3Pp = DoesContains(quote, "3PP");
quote.QuoteContainsRb = DoesContains(quote, "RB");
quote.TotalListprice = GetTotal(quote, "TotalListprice");
quote.TotalDiscount = GetTotal(quote, "AverageDiscount");
@ -84,25 +81,22 @@ namespace Gremlin_BlazorServer.Services
foreach (LineItem lineItem in quote.LineItems)
{
if (lineItem.OptionNumber != null)
// normale Gewährleistungsverlängerung
if (lineItem.OptionNumber.StartsWith("8D"))
{
// normale Gewährleistungsverlängerung
if (lineItem.OptionNumber.StartsWith("8D"))
{
quote.Warranty = int.Parse(lineItem.OptionNumber.Last().ToString()) * 12;
}
quote.Warranty = int.Parse(lineItem.OptionNumber.Last().ToString()) * 12;
}
//24 Monate Gewährleistung für Akademia
if (lineItem.OptionNumber == "9EC")
{
quote.Warranty = 24;
}
//24 Monate Gewährleistung für Akademia
if (lineItem.OptionNumber == "9EC")
{
quote.Warranty = 24;
}
//36 Monate Gewährleistung für Akademia
if (lineItem.OptionNumber == "9CC")
{
quote.Warranty = 36;
}
//36 Monate Gewährleistung für Akademia
if (lineItem.OptionNumber == "9CC")
{
quote.Warranty = 36;
}
//AddToTotal
@ -143,8 +137,6 @@ namespace Gremlin_BlazorServer.Services
private static List<LineItem> ParseClipboardList(List<string[]> lineItemStrings)
{
List<LineItem> lineItems = new();
int countError = 0;
int countEmpty = 0;
CultureInfo cultureInfoUs = new("en-US");
foreach (string[] lineItemString in lineItemStrings)
@ -155,7 +147,6 @@ namespace Gremlin_BlazorServer.Services
//Header ignorieren
if (lineItemString[0] == "#")
{
countEmpty++;
continue;
}
@ -183,8 +174,6 @@ namespace Gremlin_BlazorServer.Services
else
{
Debug.WriteLine("Angebot konnte nicht eingelesen werden!");
countError++;
continue;
}
}
return lineItems;
@ -192,8 +181,7 @@ namespace Gremlin_BlazorServer.Services
private static byte CheckForAcademic(Contact recipient)
{
if (recipient.Account.AccountType == null) { return 60; }
return (byte)(recipient == null || recipient.Account.AccountType.AccountTypeCode == null ? 0 : recipient.Account.AccountType.AccountTypeCode.StartsWith("N") ? 90 : 60);
return (byte)(recipient.Account.AccountType.AccountTypeCode.StartsWith("N") ? 90 : 60);
}
private static decimal GetFreight(decimal net, decimal freight)
@ -206,8 +194,8 @@ namespace Gremlin_BlazorServer.Services
{
quote.TotalFreightOnly = GetFreight(quote.TotalNet, quote.Freight);
quote.TotalFreight = quote.TotalNet + quote.TotalFreightOnly;
quote.TotalVAT = quote.TotalFreight * Convert.ToDecimal(quote.VAT) / 100;
quote.TotalGross = quote.TotalFreight * (100 + Convert.ToDecimal(quote.VAT)) / 100;
quote.TotalVat = quote.TotalFreight * Convert.ToDecimal(quote.Vat) / 100;
quote.TotalGross = quote.TotalFreight * (100 + Convert.ToDecimal(quote.Vat)) / 100;
return quote;
}
@ -217,7 +205,7 @@ namespace Gremlin_BlazorServer.Services
quote.TotalNet = 0;
quote.TotalFreightOnly = 0;
quote.TotalFreight = 0;
quote.TotalVAT = 0;
quote.TotalVat = 0;
quote.TotalGross = 0;
return quote;
@ -243,7 +231,7 @@ namespace Gremlin_BlazorServer.Services
}
}
if (type == "AverageDiscount" & quote.LineItems.Count != 0) { total /= quote.LineItems.Count; }
if ((type == "AverageDiscount") & (quote.LineItems.Count != 0)) { total /= quote.LineItems.Count; }
return total;
}
@ -262,7 +250,7 @@ namespace Gremlin_BlazorServer.Services
}
break;
case "RB":
if (lineItem.ProductLine == "RB" & lineItem.ProductNumber != "R2005A")
if ((lineItem.ProductLine == "RB") & (lineItem.ProductNumber != "R2005A"))
{
Debug.WriteLine($"Quote containts RB with ProductNumber {lineItem.ProductNumber}");
return true;

@ -1,6 +1,5 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Microsoft.JSInterop;
using System.Text;
using static Gremlin_BlazorServer.Data.EntityClasses.Enums;
@ -8,11 +7,11 @@ namespace Gremlin_BlazorServer.Services
{
public class TexService
{
private static GremlinContext gremlinContext = new();
public TexService(GremlinContext gC) => gremlinContext = gC;
private static GremlinContext _gremlinContext = new();
public TexService(GremlinContext gC) => _gremlinContext = gC;
private readonly AccountService accountService = new(gremlinContext);
private readonly CustomDescriptionService customDescriptionService = new(gremlinContext);
private readonly AccountService accountService = new(_gremlinContext);
private readonly CustomDescriptionService customDescriptionService = new(_gremlinContext);
public async Task<StringBuilder> CreateTexAsync(Quote quote)
{
@ -21,11 +20,11 @@ namespace Gremlin_BlazorServer.Services
return new StringBuilder(correctedTex);
}
public async Task<StringBuilder> CreateBriefkopfAsync(Contact contact, bool tex = false)
private async Task<StringBuilder> CreateBriefkopfAsync(Contact contact, bool tex = false)
{
StringBuilder briefkopf = new();
_ = contact.Gender == (byte)Enums.Gender.Male
_ = contact.Gender == (byte)Gender.Male
? briefkopf.AppendLine($"Herr {contact.FirstName} {contact.LastName}")
: briefkopf.AppendLine($"Frau {contact.FirstName} {contact.LastName}");
if (tex)
@ -56,7 +55,7 @@ namespace Gremlin_BlazorServer.Services
_ = briefkopf.AppendLine($"{account.Street}");
if (tex) { _ = briefkopf.AppendLine($"\\\\"); }
_ = briefkopf.AppendLine($"{account.ZIP} {account.City}");
_ = briefkopf.AppendLine($"{account.Zip} {account.City}");
if (tex) { _ = briefkopf.AppendLine($"\\\\"); }
return briefkopf;
@ -64,7 +63,7 @@ namespace Gremlin_BlazorServer.Services
private async Task<StringBuilder> CreateTexFileAsync(Quote quote)
{
string rand = "2"; //RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "texRand");
const string rand = "2"; //RUSettingModel.GetSettingValue(Properties.Settings.Default.userSettingID, "texRand");
StringBuilder texFile = new($"\\documentclass[a4paper,ngerman,parskip,10pt]{{scrlttr2}}\n"
+ $"\\usepackage{{lmodern}}\n"
@ -117,28 +116,22 @@ namespace Gremlin_BlazorServer.Services
_ = texFile.AppendLine($"E-Mail:&\\href{{mailto:{quote.SalesRep.EMail}}}{{{quote.SalesRep.EMail}}}\\\\");
_ = texFile.AppendLine("\\textbf{Auftragsannahme:}&\\href{mailto:salesservices\\_germany@agilent.com}{salesservices\\_germany@agilent.com}\\\\\n\\hline\n\\end{tabular}\n}\\\\");
if (quote.Recipient != null)
{
_ = texFile.Append(await CreateBriefkopfAsync(quote.Recipient, true));
}
_ = texFile.Append(await CreateBriefkopfAsync(quote.Recipient, true));
_ = texFile.AppendLine("&\\\\\n&\\\\\n\\end{tabular}\n\\vspace{1cm}\\par ");
//Anrede
if (quote.Recipient != null)
{
_ = quote.Recipient.Gender == (byte)Gender.Male
? texFile.AppendLine($"Sehr geehrter Herr {quote.Recipient.LastName},\\par ")
: texFile.AppendLine($"Sehr geehrte Frau {quote.Recipient.LastName},\\par ");
}
_ = quote.Recipient.Gender == (byte)Gender.Male
? texFile.AppendLine($"Sehr geehrter Herr {quote.Recipient.LastName},\\par ")
: texFile.AppendLine($"Sehr geehrte Frau {quote.Recipient.LastName},\\par ");
//Anschreiben
_ = texFile.AppendLine(await CreateCoverletterAsync(quote));
//RB-Disclaimer
if (quote.QuoteContainsRB)
if (quote.QuoteContainsRb)
{
_ = texFile.AppendLine(await CreateRBDisclaimerAsync(quote));
_ = texFile.AppendLine(await CreateRbDisclaimerAsync(quote));
}
//Tabelle
@ -172,29 +165,32 @@ namespace Gremlin_BlazorServer.Services
string lineItemTex = "";
CustomDescription cD = await customDescriptionService.GetCustomDescriptionAsync(lI.ProductNumber, lI.OptionNumber);
if (quote.ShowSinglePrices == true)
switch (quote.ShowSinglePrices)
{
if (!quote.ShowDiscounts)
{
case true when !quote.ShowDiscounts:
//mit Einzelpreisen
lineItemTex = lI.OptionNumber != ""
? $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {cD.DescriptionText}&{lI.Amount}&\\SI{{{lI.Total}}}{{\\sieuro}}\\\\"
: $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber})\\newline {cD.DescriptionText}&{lI.Amount}&\\SI{{{lI.Total}}}{{\\sieuro}}\\\\";
}
else if (quote.ShowDiscounts)
{
//mit Einzelpreisen und Discounts
? $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {cD.DescriptionText}&{lI.Amount}&\\SI{{{lI.Total}}}{{\\sieuro}}\\\\"
: $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber})\\newline {cD.DescriptionText}&{lI.Amount}&\\SI{{{lI.Total}}}{{\\sieuro}}\\\\";
break;
case true:
{
if (quote.ShowDiscounts)
{
//mit Einzelpreisen und Discounts
lineItemTex = lI.OptionNumber != ""
? $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {cD.DescriptionText}\\newline Listenpreis: \\SI{{{lI.ListPrice}}}{{\\sieuro}}&{lI.Amount}&\\SI{{{lI.TotalDiscount}}}{{\\%}}&\\SI{{{lI.Total}}}{{\\sieuro}}\\\\"
: $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber})\\newline {cD.DescriptionText}\\newline Listenpreis: \\SI{{{lI.ListPrice}}}{{\\sieuro}}&{lI.Amount}&\\SI{{{lI.TotalDiscount}}}{{\\%}}&\\SI{{{lI.Total}}}{{\\sieuro}}\\\\";
}
break;
}
case false:
//ohne Einzelpreise
lineItemTex = lI.OptionNumber != ""
? $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {cD.DescriptionText}\\newline Listenpreis: \\SI{{{lI.ListPrice}}}{{\\sieuro}}&{lI.Amount}&\\SI{{{lI.TotalDiscount}}}{{\\%}}&\\SI{{{lI.Total}}}{{\\sieuro}}\\\\"
: $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber})\\newline {cD.DescriptionText}\\newline Listenpreis: \\SI{{{lI.ListPrice}}}{{\\sieuro}}&{lI.Amount}&\\SI{{{lI.TotalDiscount}}}{{\\%}}&\\SI{{{lI.Total}}}{{\\sieuro}}\\\\";
}
}
else if (!quote.ShowSinglePrices)
{
//ohne Einzelpreise
lineItemTex = lI.OptionNumber != ""
? $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {cD.DescriptionText}&{lI.Amount}\\\\"
: $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber})\\newline {cD.DescriptionText}&{lI.Amount}\\\\";
? $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber}\\#{lI.OptionNumber})\\newline {cD.DescriptionText}&{lI.Amount}\\\\"
: $"{lI.Position} &\\textbf{{{cD.Heading}}} ({lI.ProductNumber})\\newline {cD.DescriptionText}&{lI.Amount}\\\\";
break;
}
_ = texFile.Append(lineItemTex + "\n");
@ -219,9 +215,9 @@ namespace Gremlin_BlazorServer.Services
_ = texFile.AppendLine($"\\textbf{{Gesamtsumme netto}} & \\SI{{{quote.TotalFreight}}}{{\\sieuro}}\\\\");
//mit Mehrwertsteuer
if (quote.ShowBrutto == true)
if (quote.ShowBrutto)
{
_ = texFile.AppendLine($"\\textbf{{Umsatzsteuer ({quote.VAT}\\%)}} & \\SI{{{quote.TotalVAT}}}{{\\sieuro}}\\\\");
_ = texFile.AppendLine($"\\textbf{{Umsatzsteuer ({quote.Vat}\\%)}} & \\SI{{{quote.TotalVat}}}{{\\sieuro}}\\\\");
_ = texFile.AppendLine($"\\textbf{{Gesamtsumme brutto}} & \\SI{{{quote.TotalGross}}}{{\\sieuro}}\\\\");
}
@ -229,9 +225,9 @@ namespace Gremlin_BlazorServer.Services
_ = texFile.AppendLine($"\\textbf{{Gewährleistung:}}\\\\\nDie Gewährleistung für Zubehör und Ersatzteilprodukte und für Analytik-Hardwareprodukte beträgt {quote.Warranty} Monate.\n");
//3PP-Disclaimer
if (quote.QuoteContains3PP)
if (quote.QuoteContains3Pp)
{
_ = texFile.AppendLine(Create3PPDisclaimer(quote));
_ = texFile.AppendLine(Create3PpDisclaimer(quote));
}
_ = texFile.AppendLine($"\\textbf{{Hinweis:}}\\\\ \n" +
@ -244,40 +240,40 @@ namespace Gremlin_BlazorServer.Services
return texFile;
}
private async Task<string> CreateRBDisclaimerAsync(Quote quote)
private async Task<string> CreateRbDisclaimerAsync(Quote quote)
{
Random r = new();
string rbDisclaimer = "\\textbf{Wichtiger Hinweis zur Bestellung von überholten Geräten}\\\\\n";
rbDisclaimer += "Bitte beachten Sie, dass in der Regel nur wenige gebrauchte Geräte auf Lager sind und diese ohne die Möglichkeit einer Reservierung auf „first come, first serve“-Basis verkauft werden. Um lange Lieferzeiten zu vermeiden, sollte daher bei konkretem Interesse zunächst der Lagerstand überprüft werden. Die aktuellen Lagerbestände sind:\n";
List<LineItem> lineItemsWithRB = quote.LineItems.Where(lI => lI.ProductLine == "RB").ToList();
List<LineItem> lineItemsWithRb = quote.LineItems.Where(lI => lI.ProductLine == "RB").ToList();
rbDisclaimer += "\\begin{center}\n\\begin{tabular}{clc}\n";
rbDisclaimer += "\\textbf{Modul} & \\textbf{Beschreibung} &\\textbf{Bestand}\\\\ \\hline \n";
foreach (LineItem lineItemWithRB in lineItemsWithRB)
foreach (LineItem lineItemWithRb in lineItemsWithRb)
{
CustomDescription customDescription = await customDescriptionService.GetCustomDescriptionAsync(lineItemWithRB.ProductNumber, lineItemWithRB.OptionNumber);
CustomDescription customDescription = await customDescriptionService.GetCustomDescriptionAsync(lineItemWithRb.ProductNumber, lineItemWithRb.OptionNumber);
int rbcount = r.Next(20) - 5; //Get count of RB?
rbDisclaimer += $"{lineItemWithRB.ProductNumber} & {customDescription.Heading} & {rbcount}\\\\ \n";
rbDisclaimer += $"{lineItemWithRb.ProductNumber} & {customDescription.Heading} & {rbcount}\\\\ \n";
}
rbDisclaimer += "\\end{tabular}\n\\end{center}\n";
return rbDisclaimer;
}
private static string Create3PPDisclaimer(Quote quote)
private static string Create3PpDisclaimer(Quote quote)
{
string dreipp = "\\textbf{Hinweis zu Non-Agilent-Produkten}\\\\ \n"
+ $"Bitte beachten Sie, dass das/die o.g. Produkt/e ";
//List all 3PP product numbers
List<LineItem> lineItemsWith3PP = quote.LineItems.Where(lI => lI.ProductLine == "3PP").ToList();
for (int i = 0; i < lineItemsWith3PP.Count; i++)
List<LineItem> lineItemsWith3Pp = quote.LineItems.Where(lI => lI.ProductLine == "3PP").ToList();
for (int i = 0; i < lineItemsWith3Pp.Count; i++)
{
_ = i < lineItemsWith3PP.Count - 1
? dreipp += $"{lineItemsWith3PP[i].ProductNumber}, "
: dreipp += $"{lineItemsWith3PP[i].ProductNumber}";
_ = i < lineItemsWith3Pp.Count - 1
? dreipp += $"{lineItemsWith3Pp[i].ProductNumber}, "
: dreipp += $"{lineItemsWith3Pp[i].ProductNumber}";
//Get all 3PP Supplier
//List<Supllier> supllier3PP = lineItemWith3PP.ProductLine.Supplier;
@ -347,7 +343,7 @@ namespace Gremlin_BlazorServer.Services
return coverLetter;
}
public static string Replace(string text)
private static string Replace(string text)
{
if (text == "")
{

@ -7,20 +7,20 @@
public string DataType { get; }
public List<string> Qualifiers { get; }
public int Score { get; private set; } = 0;
public bool AllQualifierMatched { get; private set; } = false;
public int Score { get; private set; }
public bool AllQualifierMatched { get; private set; }
public DataIdType(string DataType, IEnumerable<string> Qualifiers)
public DataIdType(string dataType, IEnumerable<string> qualifiers)
{
this.DataType = DataType;
this.Qualifiers = Qualifiers.ToList();
numberOfQualifiers = this.Qualifiers.Count;
DataType = dataType;
Qualifiers = qualifiers.ToList();
numberOfQualifiers = Qualifiers.Count;
matchedQualifiers = new();
}
public void AddFoundQualfier(string QualifierFound)
public void AddFoundQualfier(string qualifierFound)
{
matchedQualifiers.Add(QualifierFound);
matchedQualifiers.Add(qualifierFound);
Score++;
AllQualifierMatched = matchedQualifiers.Count == numberOfQualifiers;
}

@ -5,49 +5,48 @@ namespace Gremlin_BlazorServer.Services.GUClasses
internal class DataIdentificator
{
//private readonly string _source; //Qualifier-Liste
private readonly Dictionary<string, int> _mappingTable; //Mapping Spaltenzahl <-> Property/(übersetzte) Spaltenüberschrift
private readonly Dictionary<string, int> mappingTable; //Mapping Spaltenzahl <-> Property/(übersetzte) Spaltenüberschrift
public List<DataIdType> DataTypes { get; set; } = new List<DataIdType>();
public DataIdentificator(Dictionary<string, int> MappingTable)
public DataIdentificator(Dictionary<string, int> mappingTable)
{
_mappingTable = MappingTable;
mappingTable = mappingTable;
//DataTypes populieren. Dazu: einlesen, nach DT qualifier in temp. Liste speichern, damit neuen DIDT erzeugen und zur Liste hinzufügen
Initialize();
}
private void Initialize()
{
string _currentDataType;
string currentDataType;
DataTypes = new();
List<DataIdentifier> dataIdentifier = ReadDataIdentifierFromFile();
_currentDataType = dataIdentifier[0].DataType;
List<string> _identifierOfCurrentType = new();
currentDataType = dataIdentifier[0].DataType;
List<string> identifierOfCurrentType = new();
foreach (DataIdentifier qualifier in dataIdentifier)
{
if (qualifier.DataType == _currentDataType)
if (qualifier.DataType == currentDataType)
{
_identifierOfCurrentType.Add(qualifier.Identifier);
identifierOfCurrentType.Add(qualifier.Identifier);
if (qualifier == dataIdentifier[^1]) //letztes Element der Liste
{
DataIdType typeToBeAdded = new(_currentDataType, _identifierOfCurrentType);
DataIdType typeToBeAdded = new(currentDataType, identifierOfCurrentType);
DataTypes.Add(typeToBeAdded);
//_currentDataType = qualifier.DataType;
}
continue;
}
else
{
DataIdType typeToBeAdded = new(_currentDataType, _identifierOfCurrentType);
DataIdType typeToBeAdded = new(currentDataType, identifierOfCurrentType);
DataTypes.Add(typeToBeAdded);
_currentDataType = qualifier.DataType;
_identifierOfCurrentType.Clear();
_identifierOfCurrentType.Add(qualifier.Identifier);
currentDataType = qualifier.DataType;
identifierOfCurrentType.Clear();
identifierOfCurrentType.Add(qualifier.Identifier);
}
}
}
public List<string> Identify(bool MustMatchAllQualifer = true)
public List<string> Identify(bool mustMatchAllQualifer = true)
{
List<string> winners = new();
@ -55,14 +54,14 @@ namespace Gremlin_BlazorServer.Services.GUClasses
{
foreach (string qualifier in datatype.Qualifiers)
{
if (_mappingTable.ContainsKey(qualifier))
if (mappingTable.ContainsKey(qualifier))
{
datatype.AddFoundQualfier(qualifier);
}
}
}
if (MustMatchAllQualifer)
if (mustMatchAllQualifer)
{
foreach (DataIdType dataType in DataTypes) //may return multiple winners
{
@ -81,7 +80,7 @@ namespace Gremlin_BlazorServer.Services.GUClasses
//1. Remove "PL", "AccountType", "Submarket" from Winner-List, if detected datatype is "LSAG" or "Account".
//2. LSAG = Account + Contact --> when LSAG is a winner, remove "LSAG" and add "Account" and "Contact" to use their dedicated import methods.
//3. Remove any other winner, when winner is one of "PL", "AccountType", "Submarket" AND fields[].count = 2.
if (MustMatchAllQualifer == true && winners.Contains("LSAG"))
if (mustMatchAllQualifer == true && winners.Contains("LSAG"))
{
if (winners.Contains("ProductLine"))
{
@ -109,7 +108,7 @@ namespace Gremlin_BlazorServer.Services.GUClasses
}
}
if (MustMatchAllQualifer == true && winners.Contains("Account"))
if (mustMatchAllQualifer == true && winners.Contains("Account"))
{
if (winners.Contains("ProductLine"))
{
@ -127,7 +126,7 @@ namespace Gremlin_BlazorServer.Services.GUClasses
}
}
if (MustMatchAllQualifer == false && _mappingTable.Count == 2)
if (mustMatchAllQualifer == false && mappingTable.Count == 2)
{
if (winners.Contains("ProductLine"))
{