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

36 lines
995 B
C#

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<UserRoleDto, IUserRoleService>
{
public AdminUserRoleController(IUserRoleService service)
:base(service)
{
InsertForbidAsync = (role, token) =>
{
return Task.FromResult(role?.IdType == 1);
};
UpdateForbidAsync = async (id, _, token) =>
{
var role = await service.GetAsync(id, token);
return role?.IdType == 1;
};
DeleteForbidAsync = async (id, token) =>
{
var role = await service.GetAsync(id, token);
return role?.IdType == 1;
};
}
}
}