feat(api): WeekendController, getAll, фильтр по периоду
This commit is contained in:
9
PARR.API/Contracts/V1/Requests/Queries/WeekendQuery.cs
Normal file
9
PARR.API/Contracts/V1/Requests/Queries/WeekendQuery.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace PARR.API.Contracts.V1.Requests.Queries
|
||||
{
|
||||
public class WeekendQuery
|
||||
{
|
||||
public DateOnly? StartPeriod { get; set; }
|
||||
|
||||
public DateOnly? EndPeriod { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -48,12 +48,15 @@ namespace PARR.API.Controllers.V1
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.Weekend.GetAll)]
|
||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery)
|
||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] WeekendQuery weekendQuery)
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
|
||||
IQueryable<WeekendDay> query = weekendDayService.Get().OrderBy(t => t.Date);
|
||||
|
||||
if (weekendQuery.StartPeriod.HasValue && weekendQuery.EndPeriod.HasValue)
|
||||
query = query.Where(t => t.Date >= weekendQuery.StartPeriod.Value && t.Date <= weekendQuery.EndPeriod);
|
||||
|
||||
var weekends = await weekendDayService.GetPage(query, paginationFilter).ToListAsync();
|
||||
|
||||
if (!weekends.Any())
|
||||
|
||||
Reference in New Issue
Block a user