2026-01-23 16:18:56 +10:00
|
|
|
|
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;
|
2026-04-30 10:35:31 +10:00
|
|
|
|
using PARR.Core.Repositories.Interfaces;
|
2026-04-14 12:01:49 +10:00
|
|
|
|
using PARR.Domain.Common.Roles;
|
2026-01-23 16:18:56 +10:00
|
|
|
|
|
|
|
|
|
|
namespace PARR.API.Controllers.V1
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Периоды распределения РР
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
|
|
|
|
|
public class DistributionPeriodController : BaseApiController
|
|
|
|
|
|
{
|
2026-04-30 10:35:31 +10:00
|
|
|
|
private readonly IDistributionPeriodRepository distributionPeriodService;
|
2026-01-23 16:18:56 +10:00
|
|
|
|
private readonly IMapper mapper;
|
|
|
|
|
|
|
|
|
|
|
|
public DistributionPeriodController(
|
2026-04-30 10:35:31 +10:00
|
|
|
|
IDistributionPeriodRepository distributionPeriodService,
|
2026-01-23 16:18:56 +10:00
|
|
|
|
IMapper mapper
|
|
|
|
|
|
)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.distributionPeriodService = distributionPeriodService;
|
|
|
|
|
|
this.mapper = mapper;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Список периодов распределения
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet(ApiRoutes.DistributionPeriod.GetAll)]
|
|
|
|
|
|
public async Task<IActionResult> GetAll()
|
|
|
|
|
|
{
|
|
|
|
|
|
var periods = await distributionPeriodService.Get()
|
|
|
|
|
|
.OrderBy(t => t.Name)
|
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
if (!periods.Any())
|
|
|
|
|
|
return NoContent();
|
|
|
|
|
|
|
|
|
|
|
|
var response = mapper.Map<List<DistributionPeriodResponse>>(periods);
|
|
|
|
|
|
|
|
|
|
|
|
return Ok(new Response<List<DistributionPeriodResponse>>(response, true));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|