From b13b8ebfb6efa0cb19c9ccdb96caebec7ca0c869 Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Tue, 26 May 2026 10:53:10 +0100 Subject: [PATCH] Added new endpoint to manage deliveries --- .../GetAllDeliveryNotesNotArrivedEndpoint.cs | 20 +++++++++++++++++++ .../DeliveryNotes/GetAllDeliveryNoteSpec.cs | 3 ++- .../GetAllDeliveryNotesByRealDateSpec.cs | 17 ++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNotesNotArrivedEndpoint.cs create mode 100644 PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNotesByRealDateSpec.cs diff --git a/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNotesNotArrivedEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNotesNotArrivedEndpoint.cs new file mode 100644 index 0000000..07cdaeb --- /dev/null +++ b/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNotesNotArrivedEndpoint.cs @@ -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> +{ + public override void Configure() + { + Get("/deliveryNotes/validation"); + AllowAnonymous(); + } + + public override async Task HandleAsync(CancellationToken ct) + { + await Send.OkAsync(await deliveryNotesRepository.ProjectToListAsync(new GetAllDeliveryNotesByRealDateSpec(), ct), ct); + } +} \ No newline at end of file diff --git a/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNoteSpec.cs b/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNoteSpec.cs index 30ef09a..fb67cf6 100644 --- a/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNoteSpec.cs +++ b/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNoteSpec.cs @@ -11,6 +11,7 @@ public class GetAllDeliveryNoteSpec : Specification .Include(x => x.Deliverer) .Include(x => x.ProductDeliveries)! .ThenInclude(x => x.Product) - .Where(x => true); + .Where(x => true) + .OrderByDescending(x => x.ExpeditionDate); } } \ No newline at end of file diff --git a/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNotesByRealDateSpec.cs b/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNotesByRealDateSpec.cs new file mode 100644 index 0000000..041842f --- /dev/null +++ b/PyroFetes/Specifications/DeliveryNotes/GetAllDeliveryNotesByRealDateSpec.cs @@ -0,0 +1,17 @@ +using Ardalis.Specification; +using PyroFetes.Models; + +namespace PyroFetes.Specifications.DeliveryNotes; + +public class GetAllDeliveryNotesByRealDateSpec : Specification +{ + public GetAllDeliveryNotesByRealDateSpec() + { + Query + .Include(x => x.Deliverer) + .Include(x => x.ProductDeliveries)! + .ThenInclude(x => x.Product) + .Where(x => x.RealDeliveryDate == null) + .OrderByDescending(x => x.RealDeliveryDate); + } +} \ No newline at end of file