Browse Source

Fix merge problem of `GetQueryableAsync` method.

pull/22543/head
maliming 2 years ago
parent
commit
0a47bfc47c
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 17
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs

17
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs

@ -362,8 +362,21 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
public virtual async Task UpdateOrganizationAsync(Guid sourceOrganizationId, Guid? targetOrganizationId, CancellationToken cancellationToken = default) public virtual async Task UpdateOrganizationAsync(Guid sourceOrganizationId, Guid? targetOrganizationId, CancellationToken cancellationToken = default)
{ {
var sourceOrganizationUnit = await (await GetQueryableAsync<OrganizationUnit>(cancellationToken))
.Where(x => x.Id == sourceOrganizationId)
.FirstOrDefaultAsync(cancellationToken: cancellationToken);
if (sourceOrganizationUnit == null)
{
throw new EntityNotFoundException(typeof(OrganizationUnit), sourceOrganizationId);
}
var allSourceOrganizationIds = await (await GetQueryableAsync<OrganizationUnit>(cancellationToken))
.Where(x => x.Code.StartsWith(sourceOrganizationUnit.Code))
.Select(x => x.Id)
.ToListAsync(cancellationToken: cancellationToken);
var users = await (await GetQueryableAsync(cancellationToken)) var users = await (await GetQueryableAsync(cancellationToken))
.Where(x => x.OrganizationUnits.Any(r => r.OrganizationUnitId == sourceOrganizationId)) .Where(x => x.OrganizationUnits.Any(r => allSourceOrganizationIds.Contains(r.OrganizationUnitId)))
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
foreach (var user in users) foreach (var user in users)
@ -458,7 +471,7 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb
{ {
return query.Where(x => x.Id == id); return query.Where(x => x.Id == id);
} }
if (roleId.HasValue) if (roleId.HasValue)
{ {
var organizationUnitIds = (await GetQueryableAsync<OrganizationUnit>(cancellationToken)) var organizationUnitIds = (await GetQueryableAsync<OrganizationUnit>(cancellationToken))

Loading…
Cancel
Save