using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Controllers
{
///
/// Редактор ролей пользователей для админки
///
[Route("api/admin/role")]
[ApiController]
[Authorize]
public class AdminUserRoleController : CrudController
{
public AdminUserRoleController(IUserRoleService 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);
};
}
}
}