This commit is contained in:
ai.astrakhantsev 2022-11-08 12:19:50 +05:00
parent e908d6a655
commit 2e1f49e704

View File

@ -99,9 +99,7 @@ namespace AsbCloudInfrastructure.Repository
await AssertLoginIsBusyAsync(dto.Login, token);
var userRoles = await userRoleRepository.GetByNamesAsync(dto.RoleNames, token).ConfigureAwait(false);
if (userRoles is not null)
await UpdateRolesCacheForUserAsync(dto.Id, userRoles, token);
await UpdateRolesCacheForUserAsync(dto.Id, userRoles, token);
var entity = Convert(dto);
@ -127,9 +125,6 @@ namespace AsbCloudInfrastructure.Repository
public IEnumerable<UserRoleDto> GetRolesByIdUser(int idUser, int nestedLevel = 0)
{
var roles = GetCachRelationUserUserRoleCacheTag().Where(r => r.IdUser == idUser);
if (roles is null)
return Enumerable.Empty<UserRoleDto>();
return roles.SelectMany(r => userRoleRepository.GetNestedById(r.IdUserRole, nestedLevel));
}
@ -161,7 +156,7 @@ namespace AsbCloudInfrastructure.Repository
private IEnumerable<string>? GetRolesNamesByIdUser(int idUser)
=> GetRolesByIdUser(idUser, 7)
?.Select(r => r.Caption)
.Select(r => r.Caption)
.Distinct();
private async Task AssertLoginIsBusyAsync(string login, CancellationToken token = default)