feat(api): список статусов ЭК
This commit is contained in:
@@ -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}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
10
PARR.API/Contracts/V1/Responses/EkStatusResponse.cs
Normal file
10
PARR.API/Contracts/V1/Responses/EkStatusResponse.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
51
PARR.API/Controllers/V1/EkStatusController.cs
Normal file
51
PARR.API/Controllers/V1/EkStatusController.cs
Normal 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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -211,6 +211,9 @@ 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));
|
||||
|
||||
|
||||
CreateMap<EkStatus, EkStatusResponse>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace PARR.DAL
|
||||
services.AddTransient<IUserService, UserService>();
|
||||
services.AddTransient<IRoleService, RoleService>();
|
||||
services.AddTransient<ITaskStatusService, TaskStatusService>();
|
||||
services.AddTransient<IEkStatusService, EkStatusService>();
|
||||
|
||||
// TransformServices
|
||||
services.AddTransient<IEsppScheduleTransformService, EsppScheduleTransformService>();
|
||||
|
||||
20
PARR.DAL/Services/Implementations/EkStatusService.cs
Normal file
20
PARR.DAL/Services/Implementations/EkStatusService.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class EkStatusService : IEkStatusService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
|
||||
public EkStatusService(DataContext dataContext)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
}
|
||||
public IQueryable<EkStatus> Get()
|
||||
{
|
||||
return dataContext.EkStatuses;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
PARR.DAL/Services/Interfaces/IEkStatusService.cs
Normal file
9
PARR.DAL/Services/Interfaces/IEkStatusService.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using PARR.DAL.Models;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IEkStatusService
|
||||
{
|
||||
IQueryable<EkStatus> Get();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user