feat(api): jobGroup при создании и обновлении принимает поле GroupingUnitFieldId. Валидации. Контроллеры KiiUnitController, RegionalEkPtkGroupController
This commit is contained in:
57
PARR.API/Controllers/V1/KiiUnitController.cs
Normal file
57
PARR.API/Controllers/V1/KiiUnitController.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
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.Unit;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
/// <summary>
|
||||
/// Список КИИ ЭК
|
||||
/// </summary>
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class KiiUnitController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IUnitKiiUnitService unitKiiUnitService;
|
||||
|
||||
public KiiUnitController(
|
||||
IMapper mapper,
|
||||
IUnitKiiUnitService unitKiiUnitService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.unitKiiUnitService = unitKiiUnitService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Список КИИ ЭК
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.KiiUnit.GetAll)]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var query = unitKiiUnitService.Get()
|
||||
.Include(t => t.Unit)
|
||||
.Select(t => t.Unit)
|
||||
.OrderBy(t => t.Name);
|
||||
|
||||
var units = await query.ToListAsync();
|
||||
|
||||
if (!units.Any())
|
||||
return NoContent();
|
||||
|
||||
var response = mapper.Map<List<UnitBaseResponse>>(units);
|
||||
|
||||
return Ok(new Response<List<UnitBaseResponse>>(response, true));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user