|
|
|
@ -62,35 +62,35 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext, |
|
|
|
{ |
|
|
|
var dbContext = await GetDbContextAsync(); |
|
|
|
var userRoles = await (from userRole in dbContext.Set<IdentityUserRole>() |
|
|
|
join role in dbContext.Roles on userRole.RoleId equals role.Id |
|
|
|
where userIds.Contains(userRole.UserId) |
|
|
|
group new |
|
|
|
{ |
|
|
|
userRole.UserId, |
|
|
|
role.Name |
|
|
|
} by userRole.UserId |
|
|
|
join role in dbContext.Roles on userRole.RoleId equals role.Id |
|
|
|
where userIds.Contains(userRole.UserId) |
|
|
|
group new { |
|
|
|
userRole.UserId, |
|
|
|
role.Name |
|
|
|
} by userRole.UserId |
|
|
|
into gp |
|
|
|
select new IdentityUserIdWithRoleNames |
|
|
|
{ |
|
|
|
Id = gp.Key, RoleNames = gp.Select(x => x.Name).ToArray() |
|
|
|
}).ToListAsync(cancellationToken: cancellationToken); |
|
|
|
select new IdentityUserIdWithRoleNames |
|
|
|
{ |
|
|
|
Id = gp.Key, |
|
|
|
RoleNames = gp.Select(x => x.Name).ToArray() |
|
|
|
}).ToListAsync(cancellationToken: cancellationToken); |
|
|
|
|
|
|
|
var orgUnitRoles = await (from userOu in dbContext.Set<IdentityUserOrganizationUnit>() |
|
|
|
join roleOu in dbContext.Set<OrganizationUnitRole>() on userOu.OrganizationUnitId equals roleOu.OrganizationUnitId |
|
|
|
join role in dbContext.Roles on roleOu.RoleId equals role.Id |
|
|
|
where userIds.Contains(userOu.UserId) |
|
|
|
group new |
|
|
|
{ |
|
|
|
userOu.UserId, |
|
|
|
role.Name |
|
|
|
} by userOu.UserId |
|
|
|
join roleOu in dbContext.Set<OrganizationUnitRole>() on userOu.OrganizationUnitId equals roleOu.OrganizationUnitId |
|
|
|
join role in dbContext.Roles on roleOu.RoleId equals role.Id |
|
|
|
where userIds.Contains(userOu.UserId) |
|
|
|
group new { |
|
|
|
userOu.UserId, |
|
|
|
role.Name |
|
|
|
} by userOu.UserId |
|
|
|
into gp |
|
|
|
select new IdentityUserIdWithRoleNames |
|
|
|
{ |
|
|
|
Id = gp.Key, RoleNames = gp.Select(x => x.Name).ToArray() |
|
|
|
}).ToListAsync(cancellationToken: cancellationToken); |
|
|
|
select new IdentityUserIdWithRoleNames |
|
|
|
{ |
|
|
|
Id = gp.Key, |
|
|
|
RoleNames = gp.Select(x => x.Name).ToArray() |
|
|
|
}).ToListAsync(cancellationToken: cancellationToken); |
|
|
|
|
|
|
|
return userRoles.Concat(orgUnitRoles).GroupBy(x => x.Id).Select(x => new IdentityUserIdWithRoleNames {Id = x.Key, RoleNames = x.SelectMany(y => y.RoleNames).Distinct().ToArray()}).ToList(); |
|
|
|
return userRoles.Concat(orgUnitRoles).GroupBy(x => x.Id).Select(x => new IdentityUserIdWithRoleNames { Id = x.Key, RoleNames = x.SelectMany(y => y.RoleNames).Distinct().ToArray() }).ToList(); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<List<string>> GetRoleNamesInOrganizationUnitAsync( |
|
|
|
@ -196,6 +196,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext, |
|
|
|
bool includeDetails = false, |
|
|
|
Guid? roleId = null, |
|
|
|
Guid? organizationUnitId = null, |
|
|
|
Guid? id = null, |
|
|
|
string userName = null, |
|
|
|
string phoneNumber = null, |
|
|
|
string emailAddress = null, |
|
|
|
@ -215,6 +216,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext, |
|
|
|
filter, |
|
|
|
roleId, |
|
|
|
organizationUnitId, |
|
|
|
id, |
|
|
|
userName, |
|
|
|
phoneNumber, |
|
|
|
emailAddress, |
|
|
|
@ -272,6 +274,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext, |
|
|
|
string filter = null, |
|
|
|
Guid? roleId = null, |
|
|
|
Guid? organizationUnitId = null, |
|
|
|
Guid? id = null, |
|
|
|
string userName = null, |
|
|
|
string phoneNumber = null, |
|
|
|
string emailAddress = null, |
|
|
|
@ -291,6 +294,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext, |
|
|
|
filter, |
|
|
|
roleId, |
|
|
|
organizationUnitId, |
|
|
|
id, |
|
|
|
userName, |
|
|
|
phoneNumber, |
|
|
|
emailAddress, |
|
|
|
@ -434,6 +438,7 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext, |
|
|
|
string filter = null, |
|
|
|
Guid? roleId = null, |
|
|
|
Guid? organizationUnitId = null, |
|
|
|
Guid? id = null, |
|
|
|
string userName = null, |
|
|
|
string phoneNumber = null, |
|
|
|
string emailAddress = null, |
|
|
|
@ -451,6 +456,11 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext, |
|
|
|
{ |
|
|
|
var upperFilter = filter?.ToUpperInvariant(); |
|
|
|
var query = await GetQueryableAsync(); |
|
|
|
|
|
|
|
if (id.HasValue) |
|
|
|
{ |
|
|
|
return query.Where(x => x.Id == id); |
|
|
|
} |
|
|
|
|
|
|
|
if (roleId.HasValue) |
|
|
|
{ |
|
|
|
|