|
|
|
@ -126,6 +126,19 @@ namespace Volo.Abp.Identity.MongoDB |
|
|
|
.ToListAsync(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<int> GetUnaddedRolesCountAsync( |
|
|
|
OrganizationUnit organizationUnit, |
|
|
|
string filter = null, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
var roleIds = organizationUnit.Roles.Select(r => r.RoleId).ToArray(); |
|
|
|
return await DbContext.Roles.AsQueryable() |
|
|
|
.Where(r => !roleIds.Contains(r.Id)) |
|
|
|
.WhereIf(!filter.IsNullOrWhiteSpace(), r => r.Name.Contains(filter)) |
|
|
|
.As<IMongoQueryable<IdentityRole>>() |
|
|
|
.CountAsync(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<List<IdentityUser>> GetMembersAsync( |
|
|
|
OrganizationUnit organizationUnit, |
|
|
|
string sorting = null, |
|
|
|
@ -178,6 +191,22 @@ namespace Volo.Abp.Identity.MongoDB |
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<int> GetUnaddedUsersCountAsync(OrganizationUnit organizationUnit, string filter = null, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await DbContext.Users.AsQueryable() |
|
|
|
.Where(u => !u.OrganizationUnits.Any(uou => uou.OrganizationUnitId == organizationUnit.Id)) |
|
|
|
.WhereIf<IdentityUser, IMongoQueryable<IdentityUser>>( |
|
|
|
!filter.IsNullOrWhiteSpace(), |
|
|
|
u => |
|
|
|
u.UserName.Contains(filter) || |
|
|
|
u.Email.Contains(filter) || |
|
|
|
(u.PhoneNumber != null && u.PhoneNumber.Contains(filter)) |
|
|
|
) |
|
|
|
.As<IMongoQueryable<IdentityUser>>() |
|
|
|
.CountAsync(GetCancellationToken(cancellationToken)); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual Task RemoveAllRolesAsync(OrganizationUnit organizationUnit, CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
organizationUnit.Roles.Clear(); |
|
|
|
|