Fix update agentName
This commit is contained in:
@@ -168,9 +168,9 @@ public class UserService : IUserService
|
|||||||
if (string.IsNullOrEmpty(agentName))
|
if (string.IsNullOrEmpty(agentName))
|
||||||
throw new Exception("Agent name cannot be empty");
|
throw new Exception("Agent name cannot be empty");
|
||||||
|
|
||||||
// Check if agent name is already used
|
// Check if agent name is already used by another user
|
||||||
var existingUser = await _userRepository.GetUserByAgentNameAsync(agentName);
|
var existingUser = await _userRepository.GetUserByAgentNameAsync(agentName);
|
||||||
if (existingUser != null)
|
if (existingUser != null && existingUser.Id != user.Id)
|
||||||
{
|
{
|
||||||
throw new Exception($"Agent name already used by {existingUser.Name}");
|
throw new Exception($"Agent name already used by {existingUser.Name}");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user