45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
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.DAL.Services.Interfaces;
|
|
using PARR.Domain.Common.Roles;
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Список ролей пользователей
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(ApiRoutes.Role.GetAll)]
|
|
public async Task<IActionResult> GetAll()
|
|
{
|
|
var roles = await roleService.Get().OrderBy(t => t.Description).ToListAsync();
|
|
|
|
var response = mapper.Map<List<RoleResponse>>(roles);
|
|
|
|
return Ok(new Response<List<RoleResponse>>(response, true));
|
|
}
|
|
}
|
|
}
|