public IActionResult Post([FromBody] ProductEditModel model) { if (ModelState.IsValid) { var response = _ProductRepository.Create(model.ToEntity()); if (response.ResponseCode == ResponseCode.SUCCESSFUL) { return(Successful(ResponseMessage.SUCCESSFUL)); } if (response.Errors.Count > 0) { return(Errors(response.Errors)); } } return(Errors(ModelState)); }
public ActionResult Edit(ProductEditModel product) { Product currentProduct = productRepository.Find(product.Id); if (currentProduct == null) { return(RedirectToAction("index", "error", new { statusCode = 404 })); } var entity = product.ToEntity(currentProduct).MarkAsEdited(); productRepository.Update(entity); using (UnitOfWork) { UnitOfWork.Commit(); } return(RedirectToAction("details", new { category = currentProduct.CategoryName, name = currentProduct.Name })); }
public ActionResult Edit(ProductEditModel product) { Product currentProduct = productRepository.Find(product.Id); if (currentProduct == null) { return RedirectToAction("index", "error", new { statusCode = 404 }); } var entity = product.ToEntity(currentProduct).MarkAsEdited(); productRepository.Update(entity); using (UnitOfWork) { UnitOfWork.Commit(); } return RedirectToAction("details", new { category = currentProduct.CategoryName, name = currentProduct.Name }); }