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

@@ -298,6 +298,13 @@ namespace PARR.API.Contracts.V1
#endregion
public static class EkStatus
{
public const string GetAll = Base + "/ek-statuses/";
public const string getParam = "{id}";
}
}
}

View File

@@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace PARR.API.Contracts.V1.Responses
{
public class EkStatusResponse
{
public int Code { get; set; }
public string Name { get; set; } = string.Empty;
}
}

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));
}
}
}

View File

@@ -210,7 +210,10 @@ namespace PARR.API.MappingProfiles
CreateMap<ApplicationsInWork, ApplicationInWorkResponse>()
.ForMember(d => d.Work, o => o.MapFrom(s => s.Work))
.ForMember(d => d.Application, o => o.MapFrom(s => s.Application));
.ForMember(d => d.Application, o => o.MapFrom(s => s.Application));
CreateMap<EkStatus, EkStatusResponse>();
}
}
}