DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/AdminUserRoleController.cs
2024-08-19 10:01:07 +05:00

32 lines
847 B
C#

using AsbCloudApp.Data.User;
using AsbCloudApp.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers;
/// <summary>
/// Редактор ролей пользователей для админки
/// </summary>
[Route("api/admin/role")]
[ApiController]
[Authorize]
public class AdminUserRoleController : CrudController<UserRoleDto, IUserRoleRepository>
{
public AdminUserRoleController(IUserRoleRepository service)
: base(service)
{
UpdateForbidAsync = async (dto, token) =>
{
var role = await service.GetOrDefaultAsync(dto.Id, token);
return role?.Id == 1;
};
DeleteForbidAsync = (id, token) =>
{
return Task.FromResult(id == 1);
};
}
}