Fix AdminUserRoleController.*Forbid predicates.

This commit is contained in:
ngfrolov 2022-06-15 16:01:50 +05:00
parent c2608bb24b
commit 5f1de8581f
2 changed files with 4 additions and 3 deletions

View File

@ -16,19 +16,19 @@ namespace AsbCloudWebApi.Controllers
{ {
InsertForbidAsync = (role, token) => InsertForbidAsync = (role, token) =>
{ {
return Task.FromResult(role?.IdType == 1); return Task.FromResult(role?.IdType != 1);
}; };
UpdateForbidAsync = async (dto, token) => UpdateForbidAsync = async (dto, token) =>
{ {
var role = await service.GetAsync(dto.Id, token); var role = await service.GetAsync(dto.Id, token);
return role?.IdType == 1; return role?.IdType != 1;
}; };
DeleteForbidAsync = async (id, token) => DeleteForbidAsync = async (id, token) =>
{ {
var role = await service.GetAsync(id, token); var role = await service.GetAsync(id, token);
return role?.IdType == 1; return role?.IdType != 1;
}; };
} }
} }

View File

@ -127,6 +127,7 @@ namespace AsbCloudWebApi.Controllers
/// <param name="token"></param> /// <param name="token"></param>
/// <returns>1 - успешно удалено, 0 - нет</returns> /// <returns>1 - успешно удалено, 0 - нет</returns>
[HttpDelete("{id}")] [HttpDelete("{id}")]
[Permission]
public virtual async Task<ActionResult<int>> DeleteAsync(int id, CancellationToken token) public virtual async Task<ActionResult<int>> DeleteAsync(int id, CancellationToken token)
{ {
if (DeleteForbidAsync is not null && await DeleteForbidAsync(id, token)) if (DeleteForbidAsync is not null && await DeleteForbidAsync(id, token))