public JsonResult Update(SysRole role) { var old = SysRole.SingleOrDefault(role.ID); old.Name = role.Name; old.Description = role.Description; old.Update(); return(Json(ArtDialogResponseResult.SuccessResult)); }
public ActionResult Authorize(int id) { RoleAuthorizeModel model = new RoleAuthorizeModel { Role = SysRole.SingleOrDefault(id), Funcs = SysFunction.Fetch(Sql.Builder), Trees = MenuTree.Fetch(Sql.Builder), SelectedFuncIds = SysPower.Fetch("where master_id=@0 and master_type=@1", id, MasterType.Role.ToString()).Select(power => power.FunctionID) }; return(View(model)); }
public JsonResult Authorize(string functionIds, int id) { var role = SysRole.SingleOrDefault(id); // 删除权限 SysPower.Delete("where master_id in (@0) and master_type=@1", role.ID, MasterType.Role.ToString()); // 角色授权 if (string.IsNullOrEmpty(functionIds) == false) { var funcs = SysFunction.Fetch("where id in (@0)", functionIds.ToIntList()); foreach (var func in funcs) { SysPower power = new SysPower { FunctionID = func.ID, MasterID = role.ID, MasterType = MasterType.Role.ToString() }; power.Insert(); } } // 刷新用户权限 var users = SysUser.Fetch("where role_id=@0", role.ID); foreach (var user in users) { SysPower.Delete("where master_id in (@0) and master_type=@1", user.ID, MasterType.User.ToString()); var powers = SysPower.Fetch("where master_id=@0 and master_type=@1", user.RoleID, MasterType.Role.ToString()); foreach (var power in powers) { try { SysPower newPower = new SysPower { FunctionID = power.FunctionID, MasterID = user.ID, MasterType = MasterType.User.ToString() }; newPower.Insert(); } catch { } } } return(Json(ArtDialogResponseResult.SuccessResult)); }
public ActionResult Update(int id) { var role = SysRole.SingleOrDefault(id); return(View(role)); }