Exemplo n.º 1
0
 public ActionResult Create(PermissionsViewModel model)
 {
     ViewBag.Data_DepartmentID = GetSelectList();
     ServiceResult result = new ServiceResult();
     TempData["Service_Result"] = result;
     if (ModelState.IsValid)
     {
         try
         {
             Permissions entity = new Permissions();
             entity.Name = model.Name;
             entity.Description = model.Description;
             entity.Controller = model.Controller;
             entity.Action = model.Action;
             entity.Namespace = model.Namespace;
             entity.DepartmentID = model.DepartmentID;
             PermissionsService.Create(entity);
             result.Message = "添加权限成功!";
             LogHelper.WriteLog("添加权限成功");
             return RedirectToAction("index");
         }
         catch (DbEntityValidationException ex)
         {
             result.Message = Utilities.GetInnerMostException(ex);
             result.AddServiceError(result.Message);
             LogHelper.WriteLog("添加权限错误", ex);
             return View(model);
         }
     }
     else
     {
         result.Message = "请检查表单是否填写完整!";
         result.AddServiceError("请检查表单是否填写完整!");
         return View(model);
     }
 }
Exemplo n.º 2
0
 public ActionResult Edit(int ID)
 {
     PermissionsViewModel model = new PermissionsViewModel();
     var entity = PermissionsService.Find(ID);
     model.Name = entity.Name;
     model.ID = entity.ID;
     model.Description = entity.Description;
     model.Action = entity.Action;
     model.Controller = entity.Controller;
     model.Namespace = entity.Namespace;
     model.DepartmentID = entity.DepartmentID;
     ViewBag.Data_DepartmentID = GetSelectList(entity.DepartmentID);
     return View(model);
 }