exception if agentName is empty

This commit is contained in:
2025-09-04 03:42:21 +07:00
parent 1161b71dad
commit db502ede34

View File

@@ -146,6 +146,9 @@ public class UserService : IUserService
public async Task<User> UpdateAgentName(User user, string agentName)
{
if (string.IsNullOrEmpty(agentName))
throw new Exception("Agent name cannot be empty");
// Check if agent name is already used
var existingUser = await _userRepository.GetUserByAgentNameAsync(agentName);
if (existingUser != null)