Esempio n. 1
0
        public JsonResult AjaxTypeDelete(string row)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            try
            {
                TPOFormulationRawMaterialModel formulation = JsonConvert.DeserializeObject <TPOFormulationRawMaterialModel>(row);
                if (formulation != null)
                {
                    TPOFormulationRawMaterialDto dto = new TPOFormulationRawMaterialDto();
                    using (TPOFormulationRawMaterialService service = new TPOFormulationRawMaterialService())
                    {
                        Mapper.Map(formulation, dto);
                        if (formulation.ID > 0)
                        {
                            service.Delete(dto.ID);
                        }
                    }
                }

                responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulDelete);
            }
            catch (Exception exc)
            {
                responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message);
            }

            return(Json(responseMessage, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public JsonResult AjaxTypeUpdate(string row, int formulationID, int extruderID)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            try
            {
                TPOFormulationRawMaterialModel formulation = JsonConvert.DeserializeObject <TPOFormulationRawMaterialModel>(row);
                if (formulation != null)
                {
                    formulation.LastModified = DateTime.Now;

                    TPOFormulationRawMaterialDto dto = new TPOFormulationRawMaterialDto();
                    using (TPOFormulationRawMaterialService service = new TPOFormulationRawMaterialService())
                    {
                        Mapper.Map(formulation, dto);
                        dto.PlantID          = CurrentPlantId;
                        dto.TPOFormulationID = formulationID;
                        dto.TPOExtruderID    = extruderID;
                        using (RawMaterialService rawMaterialService = new RawMaterialService())
                        {
                            dto.RawMaterialCode = rawMaterialService.Get(formulation.RawMaterialID).Code;
                        }
                        if (formulation.ID > 0)
                        {
                            service.Update(dto);
                        }
                        else
                        {
                            service.Add(dto);
                        }
                    }
                }

                responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave);
            }
            catch (Exception exc)
            {
                responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message);
            }

            return(Json(responseMessage, JsonRequestBehavior.AllowGet));
        }