From 707b8f8b3b1d43ee34032bd1d9a1851de33c731e Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Wed, 15 Feb 2023 14:00:46 +0500 Subject: [PATCH] 8543610 Add exceptions for badRequest --- AsbCloudInfrastructure/Repository/UserRepository.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AsbCloudInfrastructure/Repository/UserRepository.cs b/AsbCloudInfrastructure/Repository/UserRepository.cs index d14a4727..8ddbc5f3 100644 --- a/AsbCloudInfrastructure/Repository/UserRepository.cs +++ b/AsbCloudInfrastructure/Repository/UserRepository.cs @@ -101,7 +101,8 @@ namespace AsbCloudInfrastructure.Repository var oldUser = (await GetCacheUserAsync(token)).FirstOrDefault(u => u.Id == dto.Id); if (oldUser is null) - return 0; + throw new ArgumentInvalidException + ($"Invalid id {dto.Id}. You can't edit this user.", nameof(dto)); if (oldUser.Login != dto.Login) await AssertLoginIsBusyAsync(dto.Login, token); @@ -132,7 +133,8 @@ namespace AsbCloudInfrastructure.Repository { var user = (await GetCacheUserAsync(token)).FirstOrDefault(u => u.Id == id); if (user is null) - return 0; + throw new ArgumentInvalidException + ($"Invalid id {id}. You can't edit this user.", nameof(id)); var query = dbContext .Users .Where(u => u.Id == id);