public SysPrivilege addPrivilege(SysPrivilege model)
 {
     try
     {
         db.SysPrivilege.Add(model);
         db.SaveChanges();
         return model;
     }
     catch (Exception ex)
     {
         LogUtil.Exception("ExceptionLogger", ex);
         return null;
     }
 }
 public SysPrivilege editPrivilege(SysPrivilege model)
 {
     try
     {
         db.SysPrivilege.Attach(model);
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
         return model;
     }
     catch (Exception ex)
     {
         LogUtil.Exception("ExceptionLogger", ex);
         return null;
     }
 }
Пример #3
0
 public SysPrivilege addPrivilege(SysPrivilege model)
 {
     return sysPrivilegeService.addPrivilege(model);
 }
Пример #4
0
 public SysPrivilege editPrivilege(SysPrivilege model)
 {
     return sysPrivilegeService.editPrivilege(model);
 }
        public ActionResult AddPrivilege(PrivilegeAddEdit model)
        {
            if (ModelState.IsValid)
            {
                if (systemBll.checkPrivilegeName(model.Name.Trim(), model.Menu))
                {
                    ModelState.AddModelError("errorname", "权限已存在");
                    return View(model);
                }
                var user = Session[Constants.USER_KEY] as User;
                model.Creator = user.SysOperator.ID;

                var sysPrivilege = new SysPrivilege();
                sysPrivilege.ID = -1;
                sysPrivilege.Menu = model.Menu;
                sysPrivilege.Parent = 0;
                sysPrivilege.Name = model.Name.Trim();
                sysPrivilege.Clazz = model.Clazz.Trim();
                sysPrivilege.Area = model.Area.Trim();
                sysPrivilege.Controller = model.Controller.Trim();
                sysPrivilege.Method = model.Method.Trim();
                sysPrivilege.Parameter = model.Parameter.Trim();
                sysPrivilege.Url = model.Url;
                sysPrivilege.Reserve = "";
                sysPrivilege.Remark = model.Remark;
                sysPrivilege.Creator = model.Creator;
                sysPrivilege.CreateTime = DateTime.Now;
                sysPrivilege.Auditor = model.Creator;
                var result = systemBll.addPrivilege(sysPrivilege);
                if (result == null)
                {
                    ModelState.AddModelError("errorresult", "添加失败");
                    return View(model);
                }
                return RedirectToAction("AddPrivilege", "System");
            }
            return View(model);
        }