public ActionResult Create(Rule model) { //get cutter adapter type id and check var cat = this.catService.Find(c => c.TypeName == model.CutterAdapterTypeName.Trim()); if (cat == null) { ModelState.AddModelError("CutterAdapterTypeName", "Wrong cutter adapter type"); return View(); } if (this.ruleService.CheckRFIDRule(cat.ID, model.ToolNo, model.PreSettingNo, model.ExistPipe) != null) { ModelState.AddModelError("CutterAdapterTypeName", "Rule existed"); return View(); } if (ModelState.IsValid) { model.CutterAdapterTypeID = cat.ID; model.CreateBy = this.LoginUser.UserName; model.CreateDate = DateTime.Now; this.ruleService.Add(model); return RedirectToAction("List"); } return View(); }
public bool Update(Rule model) { return this.ruleDal.Update(model); }
public bool Add(Rule model) { return this.ruleDal.Add(model); }
public ActionResult Edit(Rule model) { var updateModel = this.ruleService.Find(r => r.ID == model.ID); var cat = this.catService.Find(c => c.TypeName == model.CutterAdapterTypeName.Trim()); if (cat == null) { ModelState.AddModelError("CutterAdapterTypeName", "Wrong cutter adapter type"); return View(updateModel); } var ruleCheck = this.ruleService.CheckRFIDRule(cat.ID, model.ToolNo, model.PreSettingNo, model.ExistPipe); if (ruleCheck != null && ruleCheck.ID != model.ID) { ModelState.AddModelError("CutterAdapterTypeName", "Rule existed"); return View(updateModel); } if (ModelState.IsValid) { updateModel.CutterAdapterTypeName = model.CutterAdapterTypeName; updateModel.CutterAdapterTypeID = cat.ID; updateModel.ToolNo = model.ToolNo; updateModel.PreSettingNo = model.PreSettingNo; updateModel.UpdateBy = this.LoginUser.UserName; updateModel.UpdateDate = DateTime.Now; updateModel.IsActive = model.IsActive; updateModel.ExistPipe = model.ExistPipe; this.ruleService.Update(updateModel); return RedirectToAction("List"); } return View(); }