2024-07-04 11:02:45 +05:00
|
|
|
using AsbCloudApp.Data.User;
|
2022-10-26 15:36:49 +05:00
|
|
|
using AsbCloudApp.Repositories;
|
2021-09-10 11:28:57 +05:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2022-02-01 17:58:31 +05:00
|
|
|
using System.Threading.Tasks;
|
2021-09-10 11:28:57 +05:00
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
namespace AsbCloudWebApi.Controllers;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Редактор ролей пользователей для админки
|
|
|
|
/// </summary>
|
|
|
|
[Route("api/admin/role")]
|
|
|
|
[ApiController]
|
|
|
|
[Authorize]
|
|
|
|
public class AdminUserRoleController : CrudController<UserRoleDto, IUserRoleRepository>
|
2021-09-10 11:28:57 +05:00
|
|
|
{
|
2024-08-19 10:01:07 +05:00
|
|
|
public AdminUserRoleController(IUserRoleRepository service)
|
|
|
|
: base(service)
|
2021-09-10 11:28:57 +05:00
|
|
|
{
|
2024-08-19 10:01:07 +05:00
|
|
|
UpdateForbidAsync = async (dto, token) =>
|
2021-12-03 15:03:33 +05:00
|
|
|
{
|
2024-08-19 10:01:07 +05:00
|
|
|
var role = await service.GetOrDefaultAsync(dto.Id, token);
|
|
|
|
return role?.Id == 1;
|
|
|
|
};
|
2022-02-01 17:58:31 +05:00
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
DeleteForbidAsync = (id, token) =>
|
|
|
|
{
|
|
|
|
return Task.FromResult(id == 1);
|
|
|
|
};
|
2021-09-10 11:28:57 +05:00
|
|
|
}
|
|
|
|
}
|