public JsonResult GetScrapCodeResult(int groupID) { List <TPOLineScrapCode> model = new List <TPOLineScrapCode>(); using (TPOLineScrapCodeService svc = new TPOLineScrapCodeService()) { var dtos = svc.GetByCodeGroup(groupID); model.AddRange(Mapper.Map <List <TPOLineScrapCodeDto>, List <TPOLineScrapCode> >(dtos)); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public JsonResult DeleteCode(int id) { TPO.Web.Core.ResponseMessage responseMessage; try { using (TPOLineScrapCodeService svc = new TPOLineScrapCodeService()) { svc.Delete(id); } responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } catch (Exception exc) { responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message); } return(Json(responseMessage, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdateCodeResult(TPOLineScrapCode model) { TPO.Web.Core.ResponseMessage responseMessage; try { using (TPOLineScrapCodeService svc = new TPOLineScrapCodeService()) { var dto = Mapper.Map <TPOLineScrapCode, TPOLineScrapCodeDto>(model); dto.ModifiedBy = CurrentUser; dto.LastModified = DateTime.Now; if (dto.ID > 0) { svc.Update(dto); } else { dto.EnteredBy = CurrentUser; dto.DateEntered = DateTime.Now; dto.ID = svc.Add(dto); } model = Mapper.Map <TPOLineScrapCodeDto, TPOLineScrapCode>(dto); } responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } catch (Exception exc) { responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message); } model.ResponseMessage = responseMessage; return(Json(model, JsonRequestBehavior.AllowGet)); }