public ActionResult Create(RuleCateViewModel model) { ServiceResult result = new ServiceResult(); if (ModelState.IsValid) { try { RuleCateService.Create(model); result.Message = "添加RuleCate成功!"; LogHelper.WriteLog("添加RuleCate成功"); } catch (Exception ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加RuleCate错误", ex); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); } return Json(result); }
public ActionResult Create() { var model = new RuleCateViewModel(); ViewBag.Data_PID = Utilities.GetSelectListData( RuleCateService.GetALL().Where(x => x.PID.Equals(null)).OrderBy(x => x.Code).ToList(), x => x.ID, x => x.CateName, true); return PartialView(model); }
public RuleCate Create(RuleCateViewModel model) { var entity = new RuleCate(); entity.CateName=model.CateName; entity.PID=model.PID; entity.Code=model.Code; entity.Level=model.Level; entity.OrderIndex=model.OrderIndex; db.Add<RuleCate>(entity); db.Commit(); return entity; }
public RuleCate Update(RuleCateViewModel model) { var entity = Find(model.ID); db.Attach<RuleCate>(entity); entity.CateName=model.CateName; entity.PID=model.PID; entity.Code=model.Code; entity.Level=model.Level; entity.OrderIndex=model.OrderIndex; db.Commit(); return entity; }
public ActionResult Edit(int ID) { var entity = RuleCateService.GetALL().Single(x => x.ID == ID); var model = new RuleCateViewModel() { ID = entity.ID, CateName = entity.CateName, PID = entity.PID, Code = entity.Code, Level = entity.Level, OrderIndex = entity.OrderIndex, }; ViewBag.Data_PID = Utilities.GetSelectListData( RuleCateService.GetALL().Where(x => x.PID.Equals(null)).OrderBy(x => x.Code).ToList(), x => x.ID, x => x.CateName, model.PID, true); return PartialView(model); }