예제 #1
0
 public void Update(Permissions model)
 {
     var target = Find(model.ID);
     db.Attach<Permissions>(target);
     target.Name = model.Name;
     target.Action = model.Action;
     target.Namespace = model.Namespace;
     target.Controller = model.Controller;
     target.Description = model.Description;
     target.DepartmentID = model.DepartmentID;
     db.Commit();
 }
예제 #2
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);
     }
 }
예제 #3
0
 public void Delete(Permissions model)
 {
     var target = Find(model.ID);
     db.Remove<Permissions>(target);
     db.Commit();
 }
예제 #4
0
 public void Create(Permissions model)
 {
     db.Add<Permissions>(model);
     db.Commit();
 }