public JsonResult InsertShift(string row) { TPO.Web.Core.ResponseMessage responseMessage; ProductionShiftModel productionShift = JsonConvert.DeserializeObject <ProductionShiftModel>(row); try { if (productionShift != null) { productionShift.LastModified = DateTime.Now; productionShift.DateEntered = DateTime.Now; productionShift.EnteredBy = CurrentUser; productionShift.ModifiedBy = CurrentUser; productionShift.PlantId = CurrentPlantId; productionShift.Code = LookupShiftTypeCode(productionShift.TypeID); ProductionShiftDto dto = new ProductionShiftDto(); using (ProductionShiftService service = new ProductionShiftService()) { Mapper.Map(productionShift, dto); service.Add(dto); } } responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } catch (Exception exc) { responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message); } productionShift.ResponseMessage = responseMessage; return(Json(productionShift, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteShift(string row) { TPO.Web.Core.ResponseMessage responseMessage; ProductionShiftModel productionShift = JsonConvert.DeserializeObject <ProductionShiftModel>(row); try { if (productionShift != null && productionShift.Id > 0) { using (ProductionShiftService service = new ProductionShiftService()) { service.Delete(productionShift.Id); } } responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } catch (Exception exc) { responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message); } productionShift.ResponseMessage = responseMessage; return(Json(productionShift, JsonRequestBehavior.AllowGet)); }