Example #1
0
        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 }));
        }
Example #2
0
        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));
        }
Example #3
0
        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));
            }
        }