diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs
index fff342c1..0696bbcf 100644
--- a/PARR.API/Contracts/V1/ApiRoutes.cs
+++ b/PARR.API/Contracts/V1/ApiRoutes.cs
@@ -431,6 +431,14 @@
public const string getParam = "{id}";
}
+ public static class UnitField
+ {
+ public const string GetAll = Base + "/unit-fields/";
+ public const string Get = Base + "/unit-fields/" + getParam;
+
+ public const string getParam = "{id}";
+ }
+
#region Расписание ЕСПП
public static class EsppScheduleTypeSchedule
diff --git a/PARR.API/Controllers/UnitFieldController.cs b/PARR.API/Controllers/UnitFieldController.cs
new file mode 100644
index 00000000..0e078d5d
--- /dev/null
+++ b/PARR.API/Controllers/UnitFieldController.cs
@@ -0,0 +1,71 @@
+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;
+using PARR.API.Controllers.V1.Base;
+using PARR.Constants;
+using PARR.DAL.Services.Interfaces.Unit;
+
+namespace PARR.API.Controllers
+{
+ ///
+ /// Справочник полей
+ ///
+ [Authorize(Roles = ParrRoles.Administrator.Role)]
+ public class UnitFieldController : BaseApiController
+ {
+ private readonly ILogger logger;
+ private readonly IUnitFieldService unitFieldService;
+ private readonly IMapper mapper;
+
+ public UnitFieldController(
+ ILogger logger,
+ IUnitFieldService unitFieldService,
+ IMapper mapper
+ )
+ {
+ this.logger = logger;
+ this.unitFieldService = unitFieldService;
+ this.mapper = mapper;
+ }
+
+ ///
+ /// Список доступных в БД атрибутов ЭК
+ ///
+ ///
+ [HttpGet(ApiRoutes.UnitField.GetAll)]
+ public async Task GetAll()
+ {
+ var unitFields = await unitFieldService.Get().OrderBy(t => t.DisplayName)
+ .ToListAsync();
+
+ if (!unitFields.Any())
+ return NoContent();
+
+ var response = mapper.Map>(unitFields);
+
+ return Ok(new Response>(response, true));
+ }
+
+ ///
+ /// Получить имя атрибута по Id
+ ///
+ ///
+ [HttpGet(ApiRoutes.UnitField.Get)]
+ public async Task Get([FromRoute] Guid id)
+ {
+ var unitField = await unitFieldService.Get().FirstOrDefaultAsync(t => t.Id == id);
+
+ if (unitField == null)
+ return NoContent();
+
+ var response = mapper.Map(unitField);
+
+ return Ok(new Response(response, true));
+ }
+ }
+}
diff --git a/PARR.API/MappingProfiles/DomainToResponseProfile.cs b/PARR.API/MappingProfiles/DomainToResponseProfile.cs
index de56b81f..459207e9 100644
--- a/PARR.API/MappingProfiles/DomainToResponseProfile.cs
+++ b/PARR.API/MappingProfiles/DomainToResponseProfile.cs
@@ -353,6 +353,9 @@ namespace PARR.API.MappingProfiles
CreateMap();
+ CreateMap()
+ .ForMember(d => d.Name, o => o.MapFrom(s => (s.DisplayName == null) ? s.AihitName : s.DisplayName));
+
#region TemplateHistory
CreateMap()