Fix AdminUserRoleController.*Forbid predicates.

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

View File

@ -14,21 +14,15 @@ namespace AsbCloudWebApi.Controllers
public AdminUserRoleController(IUserRoleService service)
: base(service)
{
InsertForbidAsync = (role, token) =>
{
return Task.FromResult(role?.IdType == 1);
};
UpdateForbidAsync = async (dto, token) =>
{
var role = await service.GetAsync(dto.Id, token);
return role?.IdType == 1;
};
DeleteForbidAsync = async (id, token) =>
DeleteForbidAsync = (id, token) =>
{
var role = await service.GetAsync(id, token);
return role?.IdType == 1;
return Task.FromResult(id == 1);
};
}
}

View File

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