public void Edit(int productId, ProductCodeItem model) { var product = _productRepository.Get(productId); if (product == null) { return; } var customerData = product.CustomerProductData.FirstOrDefault(x => x.CustomerId == model.Id); if (customerData != null) { customerData.ProductCode = model.ProductCode; customerData.ProductDescription = model.ProductDescription; customerData.Gtin = model.Gtin; customerData.PricePerPound = model.PricePerPound; } else { _customerProductDataRepository.Add(new CustomerProductData { CustomerId = model.Id, ProductId = productId, ProductCode = model.ProductCode, ProductDescription = model.ProductDescription, Gtin = model.Gtin, PricePerPound = model.PricePerPound }); } _customerProductDataRepository.Save(); }
public ActionResult ProductCustomerGrid_Update([DataSourceRequest] DataSourceRequest request, int productId, ProductCodeItem customerItem) { if (customerItem != null && ModelState.IsValid) { _productService.Edit(productId, customerItem); } return(Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet)); }