diff --git a/AsbCloudApp/Data/UserDto.cs b/AsbCloudApp/Data/UserDto.cs
index 15cc5408..ed065f60 100644
--- a/AsbCloudApp/Data/UserDto.cs
+++ b/AsbCloudApp/Data/UserDto.cs
@@ -58,5 +58,25 @@
/// DTO компании
///
public CompanyDto Company { get; set; }
+
+ ///
+ /// Получение отображаемого имени
+ ///
+ ///
+ 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;
+ }
}
}
diff --git a/AsbCloudInfrastructure/Repository/UserRepository.cs b/AsbCloudInfrastructure/Repository/UserRepository.cs
index 9ea6979e..1502375a 100644
--- a/AsbCloudInfrastructure/Repository/UserRepository.cs
+++ b/AsbCloudInfrastructure/Repository/UserRepository.cs
@@ -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> GetCacheUserAsync(CancellationToken token)