feat(api): список статусов ЭК

This commit is contained in:
Mikhail Kuznetsov
2024-03-14 10:14:25 +10:00
parent fd7d5d78f3
commit ff712ed126
7 changed files with 102 additions and 1 deletions

View File

@@ -0,0 +1,51 @@
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
{
/// <summary>
/// Статусы ЭК
/// </summary>
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class EkStatusController : BaseApiController
{
private readonly IEkStatusService ekStatusService;
private readonly IMapper mapper;
public EkStatusController(
IEkStatusService ekStatusService,
IMapper mapper
)
{
this.ekStatusService = ekStatusService;
this.mapper = mapper;
}
/// <summary>
/// Получить список статусов ЭК
/// </summary>
/// <returns></returns>млни
[HttpGet(ApiRoutes.EkStatus.GetAll)]
public async Task<IActionResult> GetAll()
{
var statuses = await ekStatusService.Get().OrderBy(t => t.Name).ToListAsync();
if (!statuses.Any())
return NoContent();
var response = mapper.Map<List<EkStatusResponse>>(statuses);
return Ok(new Response<List<EkStatusResponse>>(response, true));
}
}
}