DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/AdminUserRoleController.cs

33 lines
929 B
C#
Raw Normal View History

using AsbCloudApp.Data;
2021-09-10 11:28:57 +05:00
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
2021-09-10 11:28:57 +05:00
namespace AsbCloudWebApi.Controllers
{
2022-06-16 17:37:10 +05:00
/// <summary>
/// Редактор ролей пользователей для админки
/// </summary>
2021-12-03 09:44:10 +05:00
[Route("api/admin/role")]
2021-09-10 11:28:57 +05:00
[ApiController]
[Authorize]
2022-04-11 18:00:34 +05:00
public class AdminUserRoleController : CrudController<UserRoleDto, IUserRoleService>
2021-09-10 11:28:57 +05:00
{
public AdminUserRoleController(IUserRoleService service)
2022-04-11 18:00:34 +05:00
: base(service)
{
2022-06-15 14:57:37 +05:00
UpdateForbidAsync = async (dto, token) =>
{
var role = await service.GetOrDefaultAsync(dto.Id, token);
return role?.IdType != 1;
};
DeleteForbidAsync = (id, token) =>
{
return Task.FromResult(id == 1);
};
}
2021-09-10 11:28:57 +05:00
}
}