/// <summary> /// 修改权限 /// </summary> /// <returns></returns> public CommandResult <object> ModifyPermissions(ModifyPermissionsRequestModel requestModel) { var result = new CommandResult <object>(); using (var db = new FrameContext()) { if (!_rolesService.Exist(db, a => a.Id == requestModel.RoleId)) { result.Message = "该角色在系统中已不存在,请刷新后再试"; } else if (!_leftMenusService.Exist(db, a => a.Id == requestModel.LeftMenuId)) { result.Message = "该菜单在系统中已不存在,请刷新后再试"; } else if (!_permissionsService.Exist(db, a => a.Id == requestModel.PermissionsId)) { result.Message = "该权限系统中已不存在,请刷新后再试"; } else { var entity = BaseService.Find(db, a => a.RoleId == requestModel.RoleId && a.LeftMenuId == requestModel.LeftMenuId && a.PermissionsId == requestModel.PermissionsId); if (entity != null) { entity.Have = requestModel.Have; if (!BaseService.Update(db, entity)) { result.Message = "系统未知原因"; } else { result.ResultStatus = ResultStatus.Success; } } else { var model = new LeftMenuPermissions { RoleId = requestModel.RoleId, LeftMenuId = requestModel.LeftMenuId, PermissionsId = requestModel.PermissionsId, Have = requestModel.Have }; if (!BaseService.Add(db, model)) { result.Message = "系统未知原因"; } else { result.ResultStatus = ResultStatus.Success; } } } } return(result); }
private bool ValidateFields() { if (string.IsNullOrWhiteSpace(tbName.Text)) { Global.ValidationFailed(this, RolesResources.NameNull); tbName.FocusAndSelect(); return(false); } if (!EditMode) { if (RolesService.Exist(tbName.Text)) { Global.ValidationFailed(this, RolesResources.NameDuplicate); tbName.FocusAndSelect(); return(false); } } return(true); }