public ActionResult Index(TPOFormulationModel model) { int Id; if (ModelState.IsValid) { TPOFormulationDto dto = Mapper.Map <TPOFormulationModel, TPOFormulationDto>(model); using (var service = new TPOFormulationService()) { if (model.Id > 0) { Id = model.Id; service.Update(dto); } else { dto.Extruders = 0; dto.PlantID = CurrentPlantId; dto.Description = "New Formulation"; service.Add(dto); Id = service.GetAll().Last().ID; } } SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } else { ModelState.AddModelError(string.Empty, "Please enter required fields."); SetResponseMesssage(ActionTypeMessage.FailedSave); return(View(model)); } return(RedirectToAction("Index", new { id = Id })); }
public ActionResult Index(int id = 0) { if (id == 0) { return(View(new TPOFormulationModel())); } using (var service = new TPOFormulationService()) { TPOFormulationModel model = Mapper.Map <TPOFormulationDto, TPOFormulationModel>(service.Get(id)); return(View(model)); } }