diff --git a/AsbCloudInfrastructure/Repository/UserRepository.cs b/AsbCloudInfrastructure/Repository/UserRepository.cs index 5648b21b..d14a4727 100644 --- a/AsbCloudInfrastructure/Repository/UserRepository.cs +++ b/AsbCloudInfrastructure/Repository/UserRepository.cs @@ -96,7 +96,8 @@ namespace AsbCloudInfrastructure.Repository public async Task UpdateAsync(UserExtendedDto dto, CancellationToken token) { if (dto.Id <= 1) - throw new ArgumentInvalidException($"Invalid id {dto.Id}. You can't edit this user.", nameof(dto)); + throw new ArgumentInvalidException + ($"Invalid id {dto.Id}. You can't edit this user.", nameof(dto)); var oldUser = (await GetCacheUserAsync(token)).FirstOrDefault(u => u.Id == dto.Id); if (oldUser is null) @@ -110,7 +111,8 @@ namespace AsbCloudInfrastructure.Repository var entity = dbContext.Users.FirstOrDefault(u => u.Id == dto.Id); if (entity is null) - return -1; + throw new ArgumentInvalidException + ($"Invalid id {dto.Id}. You can't edit this user.", nameof(dto)); entity.Id = dto.Id; entity.Login = dto.Login; entity.Name = dto.Name; @@ -141,7 +143,8 @@ namespace AsbCloudInfrastructure.Repository DropCacheUsers(); return result.Entity.Id; } - return -1; + throw new ArgumentInvalidException + ($"Invalid id {id}. You can't edit this user.", nameof(id)); } public IEnumerable GetRolesByIdUser(int idUser, int nestedLevel = 0)