forked from sanchezvem/pyrofetes-backend
Added spec for see all documents order by desc
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using PyroFetes.DTO.PurchaseOrder.Response;
|
using PyroFetes.DTO.PurchaseOrder.Response;
|
||||||
using PyroFetes.Repositories;
|
using PyroFetes.Repositories;
|
||||||
|
using PyroFetes.Specifications.PurchaseOrders;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.PurchaseOrders;
|
namespace PyroFetes.Endpoints.PurchaseOrders;
|
||||||
|
|
||||||
@@ -14,6 +15,6 @@ public class GetAllPurchaseOrderEndpoint(PurchaseOrdersRepository purchaseOrders
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
await Send.OkAsync(await purchaseOrdersRepository.ProjectToListAsync<GetPurchaseOrderDto>(ct), ct);
|
await Send.OkAsync(await purchaseOrdersRepository.ProjectToListAsync<GetPurchaseOrderDto>(new GetAllPurchaseOrderSpec(), ct), ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using PyroFetes.DTO.Quotation.Response;
|
using PyroFetes.DTO.Quotation.Response;
|
||||||
using PyroFetes.Repositories;
|
using PyroFetes.Repositories;
|
||||||
|
using PyroFetes.Specifications.Quotations;
|
||||||
|
|
||||||
namespace PyroFetes.Endpoints.Quotations;
|
namespace PyroFetes.Endpoints.Quotations;
|
||||||
|
|
||||||
@@ -14,6 +15,6 @@ public class GetAllQuotationEndpoint(QuotationsRepository quotationsRepository)
|
|||||||
|
|
||||||
public override async Task HandleAsync(CancellationToken ct)
|
public override async Task HandleAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
await Send.OkAsync(await quotationsRepository.ProjectToListAsync<GetQuotationDto>(ct), ct);
|
await Send.OkAsync(await quotationsRepository.ProjectToListAsync<GetQuotationDto>(new GetAllQuotationSpec(), ct), ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ public sealed class GetProductsUnderLimitSpec : Specification<Product>
|
|||||||
{
|
{
|
||||||
Query
|
Query
|
||||||
.Include(x => x.WarehouseProducts)
|
.Include(x => x.WarehouseProducts)
|
||||||
.Where(x => x.WarehouseProducts != null && x.WarehouseProducts.Sum(p => p.Quantity) < x.MinimalQuantity);
|
.Where(x => x.WarehouseProducts != null && x.WarehouseProducts.Sum(p => p.Quantity) < x.MinimalQuantity
|
||||||
|
&& !x.ProductDeliveries!.Any(d => d.DeliveryNote!.RealDeliveryDate == null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using Ardalis.Specification;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Specifications.PurchaseOrders;
|
||||||
|
|
||||||
|
public class GetAllPurchaseOrderSpec : Specification<PurchaseOrder>
|
||||||
|
{
|
||||||
|
public GetAllPurchaseOrderSpec()
|
||||||
|
{
|
||||||
|
Query
|
||||||
|
.Where(x => true)
|
||||||
|
.OrderByDescending(x => x.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using Ardalis.Specification;
|
||||||
|
using PyroFetes.Models;
|
||||||
|
|
||||||
|
namespace PyroFetes.Specifications.Quotations;
|
||||||
|
|
||||||
|
public class GetAllQuotationSpec : Specification<Quotation>
|
||||||
|
{
|
||||||
|
public GetAllQuotationSpec()
|
||||||
|
{
|
||||||
|
Query
|
||||||
|
.Where(x => true)
|
||||||
|
.OrderByDescending(x => x.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user