This commit is contained in:
2022-12-28 00:42:33 +00:00
parent d015e79043
commit 836f5f7b67
2 changed files with 12 additions and 7 deletions

View File

@@ -263,15 +263,20 @@ namespace Sockeye.Biz
//create product if not exist then import
//Get product id if exists
var ProductName = jPurchase["name"].Value<string>();
ProductName = ProductName.Replace("- Renewal", "").Replace(" Renewal", "").Replace(" RENEWAL", "").Replace("CANCELLED ", "");
var p = await ct.Product.AsNoTracking().FirstOrDefaultAsync(z => z.Name == ProductName);
ProductName = ProductName.Replace("- Renewal", "").Replace(" Renewal", "").Replace(" RENEWAL", "").Replace("CANCELLED ", "").Replace("CANCELED ", "");
var p = await ct.Product.AsNoTracking().FirstOrDefaultAsync(z => z.VendorCode == jPurchase["productCode"].Value<string>());
if (p == null)
{
//Create it here
p = new Product();
p.Name = jPurchase["name"].Value<string>();
p.Name = ProductName;
p.VendorId = 1;
p.OurCode = p.VendorCode = jPurchase["productCode"].Value<string>();
//log.LogInformation($"Importing new product name:{p.Name} - code:{p.VendorCode}");
ProductBiz biz = ProductBiz.GetBiz(ct);
p = await biz.CreateAsync(p);
}