8543610 Add exceptions for badRequest

This commit is contained in:
ngfrolov 2023-02-15 14:00:46 +05:00
parent dbbd4d5603
commit 707b8f8b3b
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7

View File

@ -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);