Added new endpoint to manage deliveries

This commit is contained in:
2026-05-26 10:53:10 +01:00
parent 57646a1417
commit b13b8ebfb6
3 changed files with 39 additions and 1 deletions
@@ -0,0 +1,20 @@
using FastEndpoints;
using PyroFetes.DTO.DeliveryNote.Response;
using PyroFetes.Repositories;
using PyroFetes.Specifications.DeliveryNotes;
namespace PyroFetes.Endpoints.DeliveryNotes;
public class GetAllDeliveryNotesNotArrivedEndpoint(DeliveryNotesRepository deliveryNotesRepository) : EndpointWithoutRequest<List<GetDeliveryNoteDto>>
{
public override void Configure()
{
Get("/deliveryNotes/validation");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)
{
await Send.OkAsync(await deliveryNotesRepository.ProjectToListAsync<GetDeliveryNoteDto>(new GetAllDeliveryNotesByRealDateSpec(), ct), ct);
}
}
@@ -11,6 +11,7 @@ public class GetAllDeliveryNoteSpec : Specification<DeliveryNote>
.Include(x => x.Deliverer)
.Include(x => x.ProductDeliveries)!
.ThenInclude(x => x.Product)
.Where(x => true);
.Where(x => true)
.OrderByDescending(x => x.ExpeditionDate);
}
}
@@ -0,0 +1,17 @@
using Ardalis.Specification;
using PyroFetes.Models;
namespace PyroFetes.Specifications.DeliveryNotes;
public class GetAllDeliveryNotesByRealDateSpec : Specification<DeliveryNote>
{
public GetAllDeliveryNotesByRealDateSpec()
{
Query
.Include(x => x.Deliverer)
.Include(x => x.ProductDeliveries)!
.ThenInclude(x => x.Product)
.Where(x => x.RealDeliveryDate == null)
.OrderByDescending(x => x.RealDeliveryDate);
}
}