using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.Constants;
using PARR.DAL.Services.Interfaces;
namespace PARR.API.Controllers.V1
{
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class RoleController : BaseApiController
{
private readonly IRoleService roleService;
private readonly IMapper mapper;
public RoleController(
IRoleService roleService,
IMapper mapper
)
{
this.roleService = roleService;
this.mapper = mapper;
}
///
/// Список ролей пользователей
///
///
[HttpGet(ApiRoutes.Role.GetAll)]
public async Task GetAll()
{
var roles = await roleService.Get().OrderBy(t => t.Description).ToListAsync();
var response = mapper.Map>(roles);
return Ok(new Response>(response, true));
}
}
}