This commit is contained in:
ai.astrakhantsev 2022-10-27 15:49:22 +05:00
parent 41d9e506bd
commit f86a9d1bc2
2 changed files with 23 additions and 3 deletions

View File

@ -58,5 +58,25 @@
/// DTO компании
/// </summary>
public CompanyDto Company { get; set; }
/// <summary>
/// Получение отображаемого имени
/// </summary>
/// <returns></returns>
public string MakeDisplayName()
{
if (string.IsNullOrEmpty(Surname))
return Login;
var s = Surname;
if (!string.IsNullOrEmpty(Name))
{
s += $"{Name[0]}.";
if (!string.IsNullOrEmpty(Patronymic))
s += $" {Patronymic[0]}.";
}
return s;
}
}
}

View File

@ -183,9 +183,9 @@ namespace AsbCloudInfrastructure.Repository
{
var existingUserDto = (await GetCacheUserAsync(token))
.FirstOrDefault(u => u.Login.ToLower() == login.ToLower());
var existingUser = Convert(existingUserDto);
if (existingUser is not null)
throw new ArgumentInvalidException($"Login {login} is busy by {existingUser.MakeDisplayName()}, id{existingUser.Id}", nameof(login));
if (existingUserDto is not null)
throw new ArgumentInvalidException($"Login {login} is busy by {existingUserDto.MakeDisplayName()}, id{existingUserDto.Id}", nameof(login));
}
private Task<IEnumerable<UserExtendedDto>> GetCacheUserAsync(CancellationToken token)