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

32 lines
847 B
C#
Raw Permalink Normal View History

using AsbCloudApp.Data.User;
using AsbCloudApp.Repositories;
2021-09-10 11:28:57 +05:00
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
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) =>
{
2024-08-19 10:01:07 +05:00
var role = await service.GetOrDefaultAsync(dto.Id, token);
return role?.Id == 1;
};
2024-08-19 10:01:07 +05:00
DeleteForbidAsync = (id, token) =>
{
return Task.FromResult(id == 1);
};
2021-09-10 11:28:57 +05:00
}
}