public ActionResult Create(ControllerViewModel model) { ServiceResult result = new ServiceResult(); TempData["Service_Result"] = result; if (ModelState.IsValid) { try { ControllerService.Create(model); result.Message = "添加控制器成功!"; LogHelper.WriteLog("添加控制器成功"); } catch (Exception ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("添加控制器错误", ex); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); } return Json(result); }
public Controller Update(ControllerViewModel model) { var entity = Find(model.ID); db.Attach<Controller>(entity); entity.Name = model.Name; entity.Description = model.Description; db.Commit(); return entity; }
public Controller Create(ControllerViewModel model) { var entity = new Controller(); entity.Name = model.Name; entity.Description = model.Description; db.Add<Controller>(entity); db.Commit(); return entity; }
public ActionResult Edit(int ID) { var entity = ControllerService.Find(ID); var model = new ControllerViewModel() { ID = entity.ID, Description = entity.Description, Name = entity.Name }; return PartialView(model); }
public ActionResult Create() { var model = new ControllerViewModel(); return PartialView(model); }