public ActionResult Edit(TPOProduct model) { model.LastModified = DateTime.Now; model.ModifiedBy = CurrentUser; model.DateEntered = DateTime.Now; model.EnteredBy = CurrentUser; model.PlantId = CurrentPlantId; if (ModelState.IsValid) { TPOProductDto dto = Mapper.Map <TPOProduct, TPOProductDto>(model); //TODO: move to service using (var service = new TPOProductService()) { if (model.Id > 0) { service.Update(dto); } else { service.Add(dto); } } SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } else { ModelState.AddModelError(string.Empty, "Please enter required fields."); SetResponseMesssage(ActionTypeMessage.FailedSave); return(View(model)); } return(RedirectToAction("Edit")); }
// // GET: /TPOProduct/Edit/5 public ActionResult Edit(int id = 0) { if (id == 0) { return(View(new TPOProduct())); } using (var service = new TPOProductService()) { TPOProduct model = Mapper.Map <TPOProductDto, TPOProduct>(service.Get(id)); return(View(model)); } }