private void setMarketplaceProductPrice(ProductAmazon product) { var request = new GetMyPriceForSKURequest { SellerId = _marketplaceCredential.MerchantId, MarketplaceId = _marketplaceCredential.MarketplaceIds.First(), SellerSKUList = new SellerSKUListType { SellerSKU = { product.EisSKU } } }; var response = _amazonClient.GetMyPriceForSKU(request); if (response.GetMyPriceForSKUResult.First().status != "Success") { _logger.LogWarning(LogEntryType.AmazonProduct, string.Format("GetMyPriceForSKURequest for \'{0}\' was unsuccessful!", product.EisSKU)); return; } // set the eisProduct's details var productOffer = response.GetMyPriceForSKUResult.First().Product.Offers.Offer.FirstOrDefault(); product.FulfilledBy = productOffer.FulfillmentChannel; product.Condition = productOffer.ItemCondition; product.ConditionNote = productOffer.ItemSubCondition; product.MapPrice = productOffer.BuyingPrice.LandedPrice.Amount; }
private void setMarketplaceProductOffer(ProductAmazon product) { var request = new GetLowestOfferListingsForSKURequest { SellerId = _marketplaceCredential.MerchantId, MarketplaceId = _marketplaceCredential.MarketplaceIds.First(), SellerSKUList = new SellerSKUListType { SellerSKU = { product.EisSKU } } }; var response = _amazonClient.GetLowestOfferListingsForSKU(request); if (response.GetLowestOfferListingsForSKUResult.First().status != "Success") { _logger.LogWarning(LogEntryType.AmazonProduct, string.Format("GetLowestOfferListingsForSKURequest for \'{0}\' was unsuccessful!", product.EisSKU)); return; } var offerResult = response.GetLowestOfferListingsForSKUResult.First().Product; // set eisProduct's offers details //product.LeadtimeShip = offerResult.LowestOfferListings.LowestOfferListing.First().Qualifiers.ShippingTime.Max; }
private void updateProductAmazon(ProductAmazon amazon) { try { var isExistAmazonProduct = true; var existingAmazonProduct = (ProductAmazon)_productService.GetMarketplaceProductInfo("Amazon", amazon.EisSKU); if (existingAmazonProduct == null) { isExistAmazonProduct = false; existingAmazonProduct = new ProductAmazon { EisSKU = amazon.EisSKU }; } // these are only known properties return from Amazon existingAmazonProduct.PackageQty = amazon.PackageQty; existingAmazonProduct.ProductTitle = amazon.ProductTitle; existingAmazonProduct.MapPrice = amazon.MapPrice; existingAmazonProduct.ProductGroup = amazon.ProductGroup; existingAmazonProduct.ProductTypeName = amazon.ProductTypeName; existingAmazonProduct.Condition = amazon.Condition; //existingAmazonProduct.WeightBox1 = amazon.WeightBox1; //existingAmazonProduct.WeightBox1Unit = amazon.WeightBox1Unit; //existingAmazonProduct.WeightBox2 = amazon.WeightBox2; //existingAmazonProduct.WeightBox2Unit = amazon.WeightBox2Unit; // convert it into Amazon product dto var amazonProductDto = new ProductAmazonDto(); CopyObject.CopyFields(existingAmazonProduct, amazonProductDto); amazonProductDto.ModifiedBy = Apps.EIS_WEBSITE; // save the changes if (isExistAmazonProduct) { _productService.UpdateProductAmazon(amazon.EisSKU, amazonProductDto); } else { _productService.SaveProductAmazon(amazonProductDto); } } catch (Exception ex) { _logger.LogError(LogEntryType.MarketplaceProductManager, EisHelper.GetExceptionMessage(ex), ex.StackTrace); } }
private static ProductAmazon extractProductAmazon(CsvReader csvReader) { var amazon = new ProductAmazon(); string eisSku = null; csvReader.TryGetField <string>("General-EisSKU", out eisSku); amazon.EisSKU = eisSku; string asin = null; csvReader.TryGetField <string>("Amazon-ASIN", out asin); amazon.ASIN = asin; decimal?price = null; csvReader.TryGetField <decimal?>("Amazon-Price", out price); amazon.Price = price; int?leadtimeShip = null; csvReader.TryGetField <int?>("Amazon-LeadtimeShip", out leadtimeShip); amazon.LeadtimeShip = leadtimeShip; int?packageQty = null; csvReader.TryGetField <int?>("Amazon-PackageQty", out packageQty); amazon.PackageQty = packageQty; int?numOfItems = null; csvReader.TryGetField <int?>("Amazon-NumOfItems", out numOfItems); amazon.NumOfItems = numOfItems; int?maxOrderQty = null; csvReader.TryGetField <int?>("Amazon-MaxOrderQty", out maxOrderQty); amazon.MaxOrderQty = maxOrderQty; string poductTitle = null; csvReader.TryGetField <string>("Amazon-ProductTitle", out poductTitle); amazon.ProductTitle = poductTitle; decimal mapPrice; csvReader.TryGetField <decimal>("Amazon-MapPrice", out mapPrice); amazon.MapPrice = mapPrice; bool?isAllowGiftWrap = null; csvReader.TryGetField <bool?>("Amazon-IsAllowGiftWrap", out isAllowGiftWrap); amazon.IsAllowGiftWrap = isAllowGiftWrap ?? false; amazon.isAllowGiftWrapSet = isAllowGiftWrap != null; bool?isAllowGiftMsg = null; csvReader.TryGetField <bool?>("Amazon-IsAllowGiftMsg", out isAllowGiftMsg); amazon.IsAllowGiftMsg = isAllowGiftMsg ?? false; amazon.isAllowGiftMsgSet = isAllowGiftMsg != null; string condition = null; csvReader.TryGetField <string>("Amazon-Condition", out condition); amazon.Condition = condition; string conditionNote = null; csvReader.TryGetField <string>("Amazon-ConditionNote", out conditionNote); amazon.ConditionNote = conditionNote; string fullFilledBy = null; csvReader.TryGetField <string>("Amazon-FulfilledBy", out fullFilledBy); amazon.FulfilledBy = fullFilledBy; string fbaSKU = null; csvReader.TryGetField <string>("Amazon-FbaSKU", out fbaSKU); amazon.FbaSKU = fbaSKU; bool?isEnabled = null; csvReader.TryGetField <bool?>("Amazon-IsEnabled", out isEnabled); amazon.IsEnabled = isEnabled ?? false; amazon.isEnabledSet = isEnabled != null; string productGroup = null; csvReader.TryGetField <string>("Amazon-ProductGroup", out productGroup); amazon.ProductGroup = productGroup; string productTypeName = null; csvReader.TryGetField <string>("Amazon-ProductTypeName", out productTypeName); amazon.ProductTypeName = productTypeName; string taxCode = null; csvReader.TryGetField <string>("Amazon-TaxCode", out taxCode); amazon.TaxCode = taxCode; //decimal? weightBox1 = null; //csvReader.TryGetField<decimal?>("Amazon-WeightBox1", out weightBox1); //amazon.WeightBox1 = weightBox1; //string weightBox1Unit = null; //csvReader.TryGetField<string>("Amazon-WeightBox1Unit", out weightBox1Unit); //amazon.WeightBox1Unit = weightBox1Unit; //decimal? weightBox2 = null; //csvReader.TryGetField<decimal?>("Amazon-WeightBox2", out weightBox2); //amazon.WeightBox2 = weightBox2; //string weightBox2Unit = null; //csvReader.TryGetField<string>("Amazon-WeightBox2Unit", out weightBox2Unit); //amazon.WeightBox2Unit = weightBox2Unit; return(amazon); }
private static ProductAmazon createProductAmazon(AmazonService.Item item, string eisSku) { var eProduct = new ProductAmazon { EisSKU = eisSku, ASIN = item.ASIN, Brand = item.ItemAttributes.Brand, Color = item.ItemAttributes.Color, EAN = item.ItemAttributes.EAN, Label = item.ItemAttributes.Label, Manufacturer = item.ItemAttributes.Manufacturer, Model = item.ItemAttributes.Model, NumOfItems = Convert.ToInt32(item.ItemAttributes.NumberOfItems), PackageQty = Convert.ToInt32(item.ItemAttributes.PackageQuantity), ProductGroup = item.ItemAttributes.ProductGroup, ProductTypeName = item.ItemAttributes.ProductTypeName, Size = item.ItemAttributes.Size, ProductTitle = item.ItemAttributes.Title, MapPrice = item.ItemAttributes.ListPrice == null ? 0 : (Convert.ToDecimal(item.ItemAttributes.ListPrice.Amount) / 100), }; // set the product images if (item.ImageSets != null) { var primaryImage = item.ImageSets.FirstOrDefault(x => x.Category == "primary"); if (primaryImage != null) { var images = new List <MediaContent>() { new MediaContent { Url = primaryImage.LargeImage.URL, Type = "LARGE", Caption = _channelName, Id = 1 } }; eProduct.Images = images; } } // set the product' item dimension var itemDimensionNode = item.ItemAttributes.ItemDimensions; if (itemDimensionNode != null) { var length = new DecimalWithUnit(parseDimensionValue(itemDimensionNode.Length), parseDimensionUnit(itemDimensionNode.Length)); var width = new DecimalWithUnit(parseDimensionValue(itemDimensionNode.Width), parseDimensionUnit(itemDimensionNode.Width)); var height = new DecimalWithUnit(parseDimensionValue(itemDimensionNode.Height), parseDimensionUnit(itemDimensionNode.Height)); var weight = new DecimalWithUnit(parseDimensionValue(itemDimensionNode.Weight), parseDimensionUnit(itemDimensionNode.Weight)); eProduct.ItemDimension = new Dimension(length, width, height, weight); } // the the product's package dimenstion var pkgDimensionNode = item.ItemAttributes.PackageDimensions; if (pkgDimensionNode != null) { var length = new DecimalWithUnit(parseDimensionValue(pkgDimensionNode.Length), parseDimensionUnit(pkgDimensionNode.Length)); var width = new DecimalWithUnit(parseDimensionValue(pkgDimensionNode.Width), parseDimensionUnit(pkgDimensionNode.Width)); var height = new DecimalWithUnit(parseDimensionValue(pkgDimensionNode.Height), parseDimensionUnit(pkgDimensionNode.Height)); var weight = new DecimalWithUnit(parseDimensionValue(pkgDimensionNode.Weight), parseDimensionUnit(pkgDimensionNode.Weight)); eProduct.PackageDimension = new Dimension(length, width, height, weight); } // get the condition type and leadtime ship of the prouduct if (item.Offers.Offer != null) { var offerNode = item.Offers.Offer.FirstOrDefault(); eProduct.Condition = offerNode == null ? string.Empty : offerNode.OfferAttributes.Condition; } return(eProduct); }
private MarketplaceProduct parsedToMarketplaceProduct(AmazonService.Item item) { try { var eProduct = new ProductAmazon { ASIN = item.ASIN, Brand = item.ItemAttributes.Brand, Color = item.ItemAttributes.Color, EAN = item.ItemAttributes.EAN, Label = item.ItemAttributes.Label, Manufacturer = item.ItemAttributes.Manufacturer, Model = item.ItemAttributes.Model, NumOfItems = Convert.ToInt16(item.ItemAttributes.NumberOfItems), PackageQty = Convert.ToInt16(item.ItemAttributes.PackageQuantity), ProductGroup = item.ItemAttributes.ProductGroup, ProductTypeName = item.ItemAttributes.ProductTypeName, Size = item.ItemAttributes.Size, ProductTitle = item.ItemAttributes.Title, MapPrice = item.ItemAttributes.ListPrice == null ? 0 : (Convert.ToDecimal(item.ItemAttributes.ListPrice.Amount) / 100), }; // set the product images if (item.ImageSets != null) { var primaryImage = item.ImageSets.FirstOrDefault(x => x.Category == "primary"); if (primaryImage != null) { var images = new List <MediaContent>() { new MediaContent { Url = primaryImage.LargeImage.URL, Type = "LARGE", Caption = ChannelName, Id = 1 } }; eProduct.Images = images; } } // set the product' item dimension var itemDimensionNode = item.ItemAttributes.ItemDimensions; if (itemDimensionNode != null) { var length = new DecimalWithUnit(parseDimensionValue(itemDimensionNode.Length), parseDimensionUnit(itemDimensionNode.Length)); var width = new DecimalWithUnit(parseDimensionValue(itemDimensionNode.Width), parseDimensionUnit(itemDimensionNode.Width)); var height = new DecimalWithUnit(parseDimensionValue(itemDimensionNode.Height), parseDimensionUnit(itemDimensionNode.Height)); var itemWeight = new DecimalWithUnit(parseDimensionValue(itemDimensionNode.Weight), parseDimensionUnit(itemDimensionNode.Weight)); //eProduct.WeightBox1 = itemWeight.Value; //eProduct.WeightBox1Unit = itemWeight.Unit; eProduct.ItemDimension = new Dimension(length, width, height, itemWeight); } // the the product's package dimenstion var pkgDimensionNode = item.ItemAttributes.PackageDimensions; if (pkgDimensionNode != null) { var length = new DecimalWithUnit(parseDimensionValue(pkgDimensionNode.Length), parseDimensionUnit(pkgDimensionNode.Length)); var width = new DecimalWithUnit(parseDimensionValue(pkgDimensionNode.Width), parseDimensionUnit(pkgDimensionNode.Width)); var height = new DecimalWithUnit(parseDimensionValue(pkgDimensionNode.Height), parseDimensionUnit(pkgDimensionNode.Height)); var pkgWeight = new DecimalWithUnit(parseDimensionValue(pkgDimensionNode.Weight), parseDimensionUnit(pkgDimensionNode.Weight)); //eProduct.WeightBox2 = pkgWeight.Value; //eProduct.WeightBox2Unit = pkgWeight.Unit; eProduct.PackageDimension = new Dimension(length, width, height, pkgWeight); } // get the condition type and leadtime ship of the prouduct if (item.Offers.Offer != null) { var offerNode = item.Offers.Offer.FirstOrDefault(); eProduct.Condition = offerNode == null ? string.Empty : offerNode.OfferAttributes.Condition; } return(eProduct); } catch (Exception ex) { _logger.LogError(LogEntryType.AmazonProduct, "Error in parsing the product item -> " + EisHelper.GetExceptionMessage(ex), ex.StackTrace); return(null); } }
private ProductAmazon parsedToMarketplaceProduct(GetMatchingProductForIdResponse response) { var xmlDoc = new XmlDocument(); var matchProductResult = response.GetMatchingProductForIdResult.First(); var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable); nsmgr.AddNamespace("ns", "http://mws.amazonservices.com/schema/Products/2011-10-01"); nsmgr.AddNamespace("ns2", "http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd"); if (matchProductResult.status != "Success") { _logger.LogWarning(LogEntryType.AmazonProduct, string.Format("GetMatchingProductForIdResponse was unsuccessful! - Id Type: {0} - {1}", matchProductResult.IdType, matchProductResult.Id)); return(null); } xmlDoc.LoadXml(matchProductResult.ToXML()); var rowNode = xmlDoc.ChildNodes[0]; var productAttrNode = rowNode.SelectSingleNode("//ns:Products/ns:Product/ns:AttributeSets/ns2:ItemAttributes", nsmgr); var featureNodes = rowNode.SelectNodes("//ns:Products/ns:Product/ns:AttributeSets/ns2:ItemAttributes/ns2:Feature", nsmgr); var smallImageNodes = rowNode.SelectNodes("//ns:Products/ns:Product/ns:AttributeSets/ns2:ItemAttributes/ns2:SmallImage", nsmgr); var binding = productAttrNode["ns2:Binding"] == null ? "0" : productAttrNode["ns2:Binding"].InnerText; var brand = productAttrNode["ns2:Brand"] == null ? "0" : productAttrNode["ns2:Brand"].InnerText; var color = productAttrNode["ns2:Color"] == null ? string.Empty : productAttrNode["ns2:Color"].InnerText; var department = productAttrNode["ns2:Department"] == null ? "0" : productAttrNode["ns2:Department"].InnerText; var gemType = productAttrNode["ns2:GemType"] == null ? "0" : productAttrNode["ns2:GemType"].InnerText; var label = productAttrNode["ns2:Label"] == null ? "0" : productAttrNode["ns2:Label"].InnerText; var manufacturer = productAttrNode["ns2:Manufacturer"] == null ? string.Empty : productAttrNode["ns2:Manufacturer"].InnerText; var metypeType = productAttrNode["ns2:MetalType"] == null ? "0" : productAttrNode["ns2:MetalType"].InnerText; var model = productAttrNode["ns2:Model"] == null ? string.Empty : productAttrNode["ns2:Model"].InnerText; var numOfItems = productAttrNode["ns2:NumberOfItems"] == null ? "0" : productAttrNode["ns2:NumberOfItems"].InnerText; var packageQty = productAttrNode["ns2:PackageQuantity"] == null ? "0" : productAttrNode["ns2:PackageQuantity"].InnerText; var partNumber = productAttrNode["ns2:PartNumber"] == null ? string.Empty : productAttrNode["ns2:PartNumber"].InnerText; var productGroup = productAttrNode["ns2:ProductGroup"] == null ? string.Empty : productAttrNode["ns2:ProductGroup"].InnerText; var productTypeName = productAttrNode["ns2:ProductTypeName"] == null ? string.Empty : productAttrNode["ns2:ProductTypeName"].InnerText; var publisher = productAttrNode["ns2:Publisher"] == null ? string.Empty : productAttrNode["ns2:Publisher"].InnerText; var title = productAttrNode["ns2:Title"] == null ? string.Empty : productAttrNode["ns2:Title"].InnerText; // get the product's features var features = new List <string>(); foreach (XmlNode node in featureNodes) { features.Add(node.InnerText); } // parse the product's images var smallImageUrls = new List <MediaContent>(); foreach (XmlNode node in smallImageNodes) { var imageNode = node["ns2:URL"]; smallImageUrls.Add(new MediaContent { Url = imageNode == null ? string.Empty : imageNode.InnerText, Caption = ChannelName, }); } var eProduct = new ProductAmazon { EisSKU = matchProductResult.Id, ProductTitle = title, NumOfItems = Convert.ToInt16(numOfItems), PackageQty = Convert.ToInt16(packageQty), ASIN = matchProductResult.Products.Product.First().Identifiers.MarketplaceASIN.ASIN, Brand = brand, Manufacturer = manufacturer, Model = model, ProductGroup = productGroup, ProductTypeName = productTypeName, Features = features, Images = smallImageUrls, }; // get the list price for MAP price var listPriceNode = productAttrNode["ns2:ListPrice"]; if (listPriceNode != null) { var amountNode = listPriceNode["ns2:Height"]; eProduct.MapPrice = amountNode == null ? 0 : Convert.ToDecimal(amountNode.InnerText); } // get the eisProduct dimension var itemDimensionNode = productAttrNode["ns2:ItemDimensions"]; if (itemDimensionNode != null) { var heightNode = itemDimensionNode["ns2:Height"]; var height = new Measurement(); if (heightNode != null) { height.Value = Convert.ToDecimal(heightNode.InnerText); height.Unit = heightNode.Attributes["Units"].Value; } var lengthNode = itemDimensionNode["ns2:Length"]; var length = new Measurement(); if (lengthNode != null) { length.Value = Convert.ToDecimal(lengthNode.InnerText); length.Unit = lengthNode.Attributes["Units"].Value; } var widthhNode = itemDimensionNode["ns2:Width"]; var width = new Measurement(); if (widthhNode != null) { width.Value = Convert.ToDecimal(widthhNode.InnerText); width.Unit = widthhNode.Attributes["Units"].Value; } var weightNode = itemDimensionNode["ns2:Weight"]; var weight = new Measurement(); if (weightNode != null) { weight.Value = Convert.ToDecimal(weightNode.InnerText); weight.Unit = weightNode.Attributes["Units"].Value; } eProduct.ItemDimension = new Dimension(length, width, height, weight); } // get the eisProduct's package dimension var packageDimensionNode = productAttrNode["ns2:PackageDimensions"]; if (packageDimensionNode != null) { var heightNode = packageDimensionNode["ns2:Height"]; var height = new Measurement(); if (heightNode != null) { height.Value = Convert.ToDecimal(heightNode.InnerText); height.Unit = heightNode.Attributes["Units"].Value; } var lengthNode = packageDimensionNode["ns2:Length"]; var length = new Measurement(); if (lengthNode != null) { length.Value = Convert.ToDecimal(lengthNode.InnerText); length.Unit = lengthNode.Attributes["Units"].Value; } var widthhNode = packageDimensionNode["ns2:Width"]; var width = new Measurement(); if (widthhNode != null) { width.Value = Convert.ToDecimal(widthhNode.InnerText); width.Unit = widthhNode.Attributes["Units"].Value; } var weightNode = packageDimensionNode["ns2:Weight"]; var weight = new Measurement(); if (weightNode != null) { weight.Value = Convert.ToDecimal(weightNode.InnerText); weight.Unit = weightNode.Attributes["Units"].Value; } eProduct.PackageDimension = new Dimension(length, width, height, weight); } return(eProduct); }
public void UpdateEisProduct(ProductAmazon model, string submittedBy) { try { using (var context = new EisInventoryContext()) { // get the existing product to update from db var product = context.products.FirstOrDefault(x => x.EisSKU == model.EisSKU); if (product == null) { return; } // determine the product type id of the marketplace product var productTypeId = getConfiguredProductTypeId(model.ProductTypeName, model.ProductGroup); product.Brand = model.Brand; product.Color = model.Color; product.EAN = model.EAN; product.Model = model.Model; product.ProductTypeId = productTypeId; // set the product' package dimension if (model.PackageDimension != null) { product.PkgLength = model.PackageDimension.Length.Value; product.PkgWidth = model.PackageDimension.Width.Value; product.PkgHeight = model.PackageDimension.Height.Value; product.PkgLenghtUnit = model.PackageDimension.Length.Unit; product.PkgWeight = model.PackageDimension.Weight.Value; product.PkgWeightUnit = model.PackageDimension.Weight.Unit; } // set the EIS product Item's dimension if (model.ItemDimension != null) { product.ItemLength = model.ItemDimension.Length.Value; product.ItemWidth = model.ItemDimension.Width.Value; product.ItemHeight = model.ItemDimension.Height.Value; product.ItemLenghtUnit = model.ItemDimension.Length.Unit; product.ItemWeight = model.ItemDimension.Weight.Value; product.ItemWeightUnit = model.ItemDimension.Weight.Unit; } product.ModifiedBy = submittedBy; product.Modified = DateTime.UtcNow; // save the changes context.SaveChanges(); } } catch (DbEntityValidationException ex) { var errorMsg = EisHelper.ParseDbEntityValidationException(ex); _logger.LogError(LogEntryType.AmazonGetInfoWorker, errorMsg, ex.StackTrace); } catch (Exception ex) { _logger.LogError(LogEntryType.AmazonGetInfoWorker, string.Format("Error in updating Amazon product details -> EisSKU: {0} <br/>Error message: {1}", model.EisSKU, EisHelper.GetExceptionMessage(ex))); } }
public int DoUpdateOrInsertAmazon(ProductAmazon model, string submittedBy) { using (var context = new EisInventoryContext()) { // check if the bigcommerce product already exists var product = context.productamazons.FirstOrDefault(x => x.EisSKU == model.EisSKU); // create new item if it doesn't exists if (product == null) { var domain = Mapper.Map <productamazon>(model); domain.CreatedBy = submittedBy; domain.Created = DateTime.UtcNow; context.productamazons.Add(domain); } else { if (!string.IsNullOrEmpty(model.ASIN)) { product.ASIN = model.ASIN; } if (model.Price != null) { product.Price = model.Price; } if (model.LeadtimeShip != null) { product.LeadtimeShip = model.LeadtimeShip; } if (model.PackageQty != null) { product.PackageQty = model.PackageQty; } if (model.NumOfItems != null) { product.NumOfItems = model.NumOfItems; } if (model.MaxOrderQty != null) { product.MaxOrderQty = model.MaxOrderQty; } if (model.ProductTitle != null) { product.ProductTitle = model.ProductTitle; } if (model.MapPrice != 0) { product.MapPrice = model.MapPrice; } if (model.isAllowGiftWrapSet) { product.IsAllowGiftWrap = model.IsAllowGiftWrap; } if (model.isAllowGiftMsgSet) { product.IsAllowGiftMsg = model.IsAllowGiftMsg; } if (model.Condition != null) { product.Condition = model.Condition; } if (model.ConditionNote != null) { product.ConditionNote = model.ConditionNote; } if (model.FulfilledBy != null) { product.FulfilledBy = model.FulfilledBy; } if (model.FbaSKU != null) { product.FbaSKU = model.FbaSKU; } if (model.isEnabledSet) { product.IsEnabled = model.IsEnabled; } if (!string.IsNullOrEmpty(model.ProductGroup)) { product.ProductGroup = model.ProductGroup; } if (model.ProductTypeName != null) { product.ProductTypeName = model.ProductTypeName; } if (model.TaxCode != null) { product.TaxCode = model.TaxCode; } //if (model.WeightBox1 != null) product.WeightBox1 = model.WeightBox1; //if (!string.IsNullOrEmpty(model.WeightBox1Unit)) product.WeightBox1Unit = model.WeightBox1Unit; //if (model.WeightBox2 != null) product.WeightBox2 = model.WeightBox2; //if (!string.IsNullOrEmpty(model.WeightBox2Unit)) product.WeightBox2Unit = model.WeightBox2Unit; product.ModifiedBy = submittedBy; product.Modified = DateTime.UtcNow; } // save the changes context.SaveChanges(); } return(1); }