public async Task <POContempoOutput> UpdatePOObject(POContempoOutput poobject, MMSProductEvent product, POSkus posku) { try { var prodhierarchy = await _lookUpService.GetProductHierarchy(product.SubClass); var productlabelcode = await _lookUpService.GetProductLabelDescription(product.LabelType); //check if exists if (poobject.POSkus != null && poobject.POSkus.Count > 0 && poobject.POSkus.Exists(y => y.SKU == posku.SKU) && (product?.Department == "JEP" || product?.Department == "JSF") && product?.SubClass != "JOSAC") { var poskutobeupdated = poobject.POSkus.Find(y => y.SKU == posku.SKU); poskutobeupdated.POProduct.Class = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Class; poskutobeupdated.POProduct.CountryOfOrigin = product?.ProductVendors?.Find(y => y.Sku == product.Sku && y.SubVendor == poobject.SubVendor)?.CountryOfOrigin; poskutobeupdated.POProduct.SubClass = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.SubClass; poskutobeupdated.POProduct.APVendor = posku.POProduct?.APVendor; poskutobeupdated.POProduct.VendorSKUCode = product?.ProductVendors?.Find(y => y.Sku == product.Sku && y.SubVendor == poobject.SubVendor)?.VendorSkuCode; poskutobeupdated.POProduct.ClassLevelDesc = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Description; poskutobeupdated.POProduct.Size = posku.POProduct?.Size; poskutobeupdated.POProduct.LabelType = product?.LabelType; //TODO //This LabelDescription value should be populated from "MMSProductEvent" ProductVendors objects labeldescription //For now, it is coming from database so that we know the value is populating. poskutobeupdated.POProduct.LabelDescription = productlabelcode?.Description; poskutobeupdated.POProduct.SkuDesc = product?.SkuDescShrt; poskutobeupdated.POProduct.SubClassLevelDesc = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.SubclassDescription; poskutobeupdated.POProduct.RetailPrice = posku.GetRetailPrice(); //Update CreateDate value once it is available in POSkus object poskutobeupdated.CreateDate = posku.CreateDate != null ? posku.CreateDate.Value : new DateTime?(); poskutobeupdated.ModifiedDate = posku.ModifiedDate != null ? posku.ModifiedDate.Value : new DateTime?(); } else { if ((product?.Department == "JEP" || product?.Department == "JSF") && product?.SubClass != "JOSAC") { POContempoProductOutput poProductOutput = new POContempoProductOutput { LabelType = product?.LabelType, //TODO - need to figure out how we're getting these from MMS //This LabelDescription value should be populated from "MMSProductEvent" ProductVendors objects labeldescription //For now, it is coming from database so that we know the value is populating. LabelDescription = productlabelcode?.Description, Class = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Class, CountryOfOrigin = posku.POProduct?.CountryOfOrigin, SubClass = prodhierarchy.Find(y => y.SubClass == product?.SubClass)?.SubClass, APVendor = posku.POProduct?.APVendor, VendorSKUCode = product?.ProductVendors?.Find(y => y.Sku == product?.Sku && y.SubVendor == poobject.SubVendor)?.VendorSkuCode, ClassLevelDesc = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Description, Size = posku.POProduct?.Size, SkuDesc = product?.SkuDescShrt, SubClassLevelDesc = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.SubclassDescription, RetailPrice = posku.GetRetailPrice() }; POContempoSkuOutput POSkusOutput = new POContempoSkuOutput { SKU = posku.SKU, BuyQuanity = posku.BuyQuantity != null?Convert.ToInt32(posku.BuyQuantity) : 0, POProduct = poProductOutput, //Update CreateDate value once it is available in POSkus object CreateDate = posku.CreateDate != null ? posku.CreateDate.Value : new DateTime?(), ModifiedDate = posku.ModifiedDate != null ? posku.ModifiedDate.Value : new DateTime?(), StatusCode = posku.StatusCode, }; if (poobject.POSkus == null) { poobject.POSkus = new System.Collections.Generic.List <POContempoSkuOutput>(); } poobject.POSkus.Add(POSkusOutput); } } return(poobject); } catch (Exception ex) { _logger.LogError(ex, "UpdatePOObject - Failed Updating ContempoPO: {Reason}", ex.Message); return(null); } }
public async Task <POFineLineOutput> UpdatePOObject(POFineLineOutput poobject, MMSProductEvent product, POSkus posku) { try { var prodhierarchy = await _lookUpService.GetProductHierarchy(product.SubClass); var productlabel = await _lookUpService.GetProductLabelDescription(product.LabelType); //check if exists if (poobject.POSkus != null && poobject.POSkus.Count > 0 && poobject.POSkus.Exists(y => y.SKUNumber == posku.SKU)) { var poskutobeupdated = poobject.POSkus.Find(y => y.SKUNumber == posku.SKU); poskutobeupdated.POProduct.SKUDescription = product?.SkuDescShrt; poskutobeupdated.POProduct.SubClassID = product?.SubClass; poskutobeupdated.POProduct.TicketType = productlabel?.Code; poskutobeupdated.POProduct.TicketDescription = productlabel?.Description; poskutobeupdated.POProduct.VendorNumber = posku.POProduct?.APVendor; poskutobeupdated.POProduct.Size = product?.Size; poskutobeupdated.POProduct.ISOCountryCode = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.CountryOfOrigin; poskutobeupdated.POProduct.ClassID = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Class; poskutobeupdated.POProduct.ClassDescription = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Description; poskutobeupdated.POProduct.VendorStyleNumber = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.VendorSkuCode; poskutobeupdated.POProduct.SubClassDescription = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.SubclassDescription; poskutobeupdated.POProduct.SubVendorNumber = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.SubVendor; poskutobeupdated.POProduct.TicketRetail = posku.GetRetailPrice(); return(poobject); } else { POFineLineProductOutput poFLProductOutput = new POFineLineProductOutput { VendorNumber = posku.POProduct?.APVendor, SubVendorNumber = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.SubVendor, SKUDescription = product?.SkuDescShrt, VendorStyleNumber = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.VendorSkuCode, TicketType = productlabel?.Code, TicketDescription = productlabel?.Description, ClassID = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Class, ClassDescription = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.Description, SubClassID = product?.SubClass, SubClassDescription = prodhierarchy?.Find(y => y.SubClass == product?.SubClass)?.SubclassDescription, Size = product?.Size, ISOCountryCode = product.ProductVendors?.Find(y => y.Sku == posku.SKU)?.CountryOfOrigin, TicketRetail = posku.GetRetailPrice() }; POFineLineSkuOutput POFLSkusOutput = new POFineLineSkuOutput { SKUNumber = posku.SKU, PurchaseOrderDate = posku.CreateDate != null ? posku.CreateDate.Value : new DateTime?(), PurchaseOrderReviseDate = posku.ModifiedDate != null ? posku.ModifiedDate.Value : new DateTime?(), OrderQuantity = posku.BuyQuantity != null?Convert.ToInt32(posku.BuyQuantity) : 0, POProduct = poFLProductOutput, StatusCode = posku.StatusCode, }; if (poobject.POSkus == null) { poobject.POSkus = new System.Collections.Generic.List <POFineLineSkuOutput>(); } poobject.POSkus.Add(POFLSkusOutput); return(poobject); } } catch (Exception ex) { _logger.LogError(ex, "UpdatePOObject - Failed Updating FineLinePO: {Reason} -- {PONumber} -- {Sku }", ex.Message, poobject.PurchaseOrder, posku.SKU); return(null); } }