diff --git a/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNotesNotArrivedEndpoint.cs b/PyroFetes/Endpoints/DeliveryNotes/GetAllDeliveryNotesNotArrivedEndpoint.cs new file mode 100644 index 00000000..07cdaeb2 --- /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 30ef09ab..fb67cf65 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 00000000..041842f6 --- /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