forked from ddrilling/AsbCloudServer
8543610 Add exceptions for badRequest
This commit is contained in:
parent
dbbd4d5603
commit
707b8f8b3b
@ -101,7 +101,8 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
|
|
||||||
var oldUser = (await GetCacheUserAsync(token)).FirstOrDefault(u => u.Id == dto.Id);
|
var oldUser = (await GetCacheUserAsync(token)).FirstOrDefault(u => u.Id == dto.Id);
|
||||||
if (oldUser is null)
|
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)
|
if (oldUser.Login != dto.Login)
|
||||||
await AssertLoginIsBusyAsync(dto.Login, token);
|
await AssertLoginIsBusyAsync(dto.Login, token);
|
||||||
@ -132,7 +133,8 @@ namespace AsbCloudInfrastructure.Repository
|
|||||||
{
|
{
|
||||||
var user = (await GetCacheUserAsync(token)).FirstOrDefault(u => u.Id == id);
|
var user = (await GetCacheUserAsync(token)).FirstOrDefault(u => u.Id == id);
|
||||||
if (user is null)
|
if (user is null)
|
||||||
return 0;
|
throw new ArgumentInvalidException
|
||||||
|
($"Invalid id {id}. You can't edit this user.", nameof(id));
|
||||||
var query = dbContext
|
var query = dbContext
|
||||||
.Users
|
.Users
|
||||||
.Where(u => u.Id == id);
|
.Where(u => u.Id == id);
|
||||||
|
Loading…
Reference in New Issue
Block a user