43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using AutoMapper;
|
|
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;
|
|
|
|
namespace PARR.API.Controllers.V1
|
|
{
|
|
public class StatusTemplateController : BaseApiController
|
|
{
|
|
private readonly IMapper mapper;
|
|
private readonly IStatusTemplateService statusTemplateService;
|
|
|
|
public StatusTemplateController(
|
|
IMapper mapper,
|
|
IStatusTemplateService statusTemplateService
|
|
)
|
|
{
|
|
this.mapper = mapper;
|
|
this.statusTemplateService = statusTemplateService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Получить список статусов
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(ApiRoutes.StatusTemplate.GetAll)]
|
|
public async Task<IActionResult> GetAll()
|
|
{
|
|
var statusList = await statusTemplateService.Get()
|
|
.OrderBy(t => t.Code)
|
|
.ToListAsync();
|
|
|
|
var response = mapper.Map<List<StatusTemplateResponse>>(statusList);
|
|
|
|
return Ok(new Response<List<StatusTemplateResponse>>(response, true));
|
|
}
|
|
}
|
|
}
|