public ActionResult ProductPost(ProductDTO productDTO) { if (!ModelState.IsValid) throw new HttpException(400, "Invalid data."); Product myProduct = _mapper.MapProductDTO(productDTO); if (_productService.Exists(productDTO.ProductId)) _productService.Update(myProduct); else _productService.Insert(myProduct); return RedirectToAction("ProductsAndCategories"); }
public Product MapProductDTO(ProductDTO input) { Product output = new Product(); output.Description = input.Description; output.IsActive = input.IsActive; output.IsInformationProvided = input.IsInformationProvided; output.IsTaxable = input.IsTaxable; output.Notes = input.Notes; output.ProductCategoryId = input.ProductCategoryId; output.ProductId = input.ProductId; output.UnitPrice = input.UnitPrice; return output; }