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 JsonResult GetAllFormulationResult() { List <TPOFormulationModel> formulations = new List <TPOFormulationModel>(); using (TPOFormulationService svc = new TPOFormulationService()) { var dtos = svc.GetAll(); formulations.AddRange(Mapper.Map <List <TPOFormulationDto>, List <TPOFormulationModel> >(dtos)); } return(Json(formulations, JsonRequestBehavior.AllowGet)); }