public async Task <bool> RevokeRole(User user, RoleType roleType) { if (user == null) { throw new EntityNotFoundException("User not found"); } var query = RoleTypeSmartEnum.FromValue((int)roleType).Revoke(user.Id); return(await database.Execute(query)); }
public static SqlQuery BuildIsPermittedQuery(int userId, params RoleType[] roleTypes) { string rolesConditions = string.Empty; roleTypes.ToList() .ForEach(r => rolesConditions += RoleTypeSmartEnum.FromValue((int)r).IsPermitted().Query); return(new SqlBuilder() .Exists(new SqlBuilder() .Select() .From(RepositoryDictionary.FindTable(typeof(IUserRepository))) .Where("id") .Equals .Append(userId) .And .Open .Append(rolesConditions) .Build()) .Close .As("IsPermitted") .Build()); }
public async Task <bool> RevokeRole(int userId, RoleType roleType) { var query = RoleTypeSmartEnum.FromValue((int)roleType).Revoke(userId); return(await database.Execute(query)); }