57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
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.DAL.Services.Interfaces.Unit;
|
|
using PARR.Domain.Common.Roles;
|
|
|
|
namespace PARR.API.Controllers.V1
|
|
{
|
|
/// <summary>
|
|
/// Региональные ЭК ПТК для групповых работ
|
|
/// </summary>
|
|
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
|
public class RegionalEkPtkGroupController : BaseApiController
|
|
{
|
|
private readonly IMapper mapper;
|
|
private readonly IUnitRegionalEkPtkGroupService unitRegionalEkPtkGroupService;
|
|
|
|
public RegionalEkPtkGroupController(
|
|
IMapper mapper,
|
|
IUnitRegionalEkPtkGroupService unitRegionalEkPtkGroupService
|
|
)
|
|
{
|
|
this.mapper = mapper;
|
|
this.unitRegionalEkPtkGroupService = unitRegionalEkPtkGroupService;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Региональные ЭК ПТК для групповых работ
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet(ApiRoutes.RegionalEkPtkGroup.GetAll)]
|
|
public async Task<IActionResult> GetAll()
|
|
{
|
|
var query = unitRegionalEkPtkGroupService.Get()
|
|
.Include(t => t.FieldValue)
|
|
.Select(t => t.FieldValue)
|
|
.OrderBy(t => t.Value);
|
|
|
|
var objs = await query.ToListAsync();
|
|
|
|
if (!objs.Any())
|
|
return NoContent();
|
|
|
|
var response = mapper.Map<List<UnitFieldValueResponse>>(objs);
|
|
|
|
return Ok(new Response<List<UnitFieldValueResponse>>(response, true));
|
|
|
|
}
|
|
}
|
|
}
|