forked from sanchezvem/pyrofetes-backend
Added new endpoint to manage deliveries
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user