IList <POContempoSkuOutput> ITypeConverter <POO, IList <POContempoSkuOutput> > .Convert(POO source, IList <POContempoSkuOutput> destination, ResolutionContext context) { List <POContempoSkuOutput> poSkus = new List <POContempoSkuOutput>(); source.POSkus?.ToList().ForEach(x => { if ((x.POProduct.Department == "JEP" || x.POProduct.Department == "JSF") && x.POProduct.SubClass != "JOSAC") { POContempoProductOutput poCntmpProductOutput = new POContempoProductOutput { APVendor = x.POProduct.APVendor, Class = x.POProduct.Class, ClassLevelDesc = x.POProduct.ClassDescription, SubClass = x.POProduct.SubClass, SubClassLevelDesc = x.POProduct.SubclassDescription, Size = x.POProduct.Size, CountryOfOrigin = x.POProduct.CountryOfOrigin, SkuDesc = x.POProduct.SkuDescShrt, VendorSKUCode = x.POProduct.VendorSkuCode, LabelType = x.POProduct?.LabelType, LabelDescription = x.POProduct?.LabelDescription, RetailPrice = x.GetRetailPrice() }; poSkus.Add(new POContempoSkuOutput { SKU = x.SKU, BuyQuanity = x.BuyQuantity != null ? Convert.ToInt32(x.BuyQuantity) : 0, POProduct = poCntmpProductOutput, //POSkus object is updated with CreateDate property. CreateDate = x.CreateDate != null ? x.CreateDate.Value : new DateTime?(), ModifiedDate = x.ModifiedDate != null ? x.ModifiedDate.Value : new DateTime?(), StatusCode = x.StatusCode, }); } }); return(poSkus); }
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); } }