diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs
index 41e1d87d..be60ca06 100644
--- a/PARR.API/Contracts/V1/ApiRoutes.cs
+++ b/PARR.API/Contracts/V1/ApiRoutes.cs
@@ -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}";
+ }
+
}
}
diff --git a/PARR.API/Contracts/V1/Responses/EkStatusResponse.cs b/PARR.API/Contracts/V1/Responses/EkStatusResponse.cs
new file mode 100644
index 00000000..280736e5
--- /dev/null
+++ b/PARR.API/Contracts/V1/Responses/EkStatusResponse.cs
@@ -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;
+ }
+}
diff --git a/PARR.API/Controllers/V1/EkStatusController.cs b/PARR.API/Controllers/V1/EkStatusController.cs
new file mode 100644
index 00000000..4bedc35b
--- /dev/null
+++ b/PARR.API/Controllers/V1/EkStatusController.cs
@@ -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
+{
+ ///
+ /// Статусы ЭК
+ ///
+ [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;
+ }
+
+
+ ///
+ /// Получить список статусов ЭК
+ ///
+ /// млни
+ [HttpGet(ApiRoutes.EkStatus.GetAll)]
+ public async Task GetAll()
+ {
+ var statuses = await ekStatusService.Get().OrderBy(t => t.Name).ToListAsync();
+
+ if (!statuses.Any())
+ return NoContent();
+
+ var response = mapper.Map>(statuses);
+
+ return Ok(new Response>(response, true));
+ }
+
+ }
+}
diff --git a/PARR.API/MappingProfiles/DomainToResponseProfile.cs b/PARR.API/MappingProfiles/DomainToResponseProfile.cs
index cee5f5ef..050a849b 100644
--- a/PARR.API/MappingProfiles/DomainToResponseProfile.cs
+++ b/PARR.API/MappingProfiles/DomainToResponseProfile.cs
@@ -210,7 +210,10 @@ namespace PARR.API.MappingProfiles
CreateMap()
.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();
}
}
}
diff --git a/PARR.DAL/ParrDalInstaller.cs b/PARR.DAL/ParrDalInstaller.cs
index d45f81c1..cb2f60ad 100644
--- a/PARR.DAL/ParrDalInstaller.cs
+++ b/PARR.DAL/ParrDalInstaller.cs
@@ -61,6 +61,7 @@ namespace PARR.DAL
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
// TransformServices
services.AddTransient();
diff --git a/PARR.DAL/Services/Implementations/EkStatusService.cs b/PARR.DAL/Services/Implementations/EkStatusService.cs
new file mode 100644
index 00000000..d14b7f2e
--- /dev/null
+++ b/PARR.DAL/Services/Implementations/EkStatusService.cs
@@ -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 Get()
+ {
+ return dataContext.EkStatuses;
+ }
+ }
+}
diff --git a/PARR.DAL/Services/Interfaces/IEkStatusService.cs b/PARR.DAL/Services/Interfaces/IEkStatusService.cs
new file mode 100644
index 00000000..8b925b54
--- /dev/null
+++ b/PARR.DAL/Services/Interfaces/IEkStatusService.cs
@@ -0,0 +1,9 @@
+using PARR.DAL.Models;
+
+namespace PARR.DAL.Services.Interfaces
+{
+ public interface IEkStatusService
+ {
+ IQueryable Get();
+ }
+}