forked from sanchezvem/pyrofetes-backend
Refactor all code
This commit is contained in:
@@ -3,7 +3,7 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.Deliverers;
|
||||
|
||||
public sealed class GetDelivererByIdSpec : Specification<Deliverer>
|
||||
public sealed class GetDelivererByIdSpec : SingleResultSpecification<Deliverer>
|
||||
{
|
||||
public GetDelivererByIdSpec(int delivererId)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using Ardalis.Specification;
|
||||
using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.DeliveryNotes;
|
||||
|
||||
public class GetAllDeliveryNoteSpec : Specification<DeliveryNote>
|
||||
{
|
||||
public GetAllDeliveryNoteSpec()
|
||||
{
|
||||
Query
|
||||
.Include(x => x.Deliverer)
|
||||
.Include(x => x.ProductDeliveries)!
|
||||
.ThenInclude(x => x.Product)
|
||||
.Where(x => true);
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,14 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.DeliveryNotes;
|
||||
|
||||
public sealed class GetDeliveryNoteByIdSpec : Specification<DeliveryNote>
|
||||
public sealed class GetDeliveryNoteByIdSpec : SingleResultSpecification<DeliveryNote>
|
||||
{
|
||||
public GetDeliveryNoteByIdSpec(int deliveryNoteId)
|
||||
{
|
||||
Query
|
||||
.Include(x => x.Deliverer)
|
||||
.Include(x => x.ProductDeliveries!)
|
||||
.ThenInclude(x => x.Product)
|
||||
.Where(x => x.Id == deliveryNoteId);
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.DeliveryNotes;
|
||||
|
||||
public class GetDeliveryNoteByIdWithProductsSpec : Specification<DeliveryNote>
|
||||
public class GetDeliveryNoteByIdWithProductsSpec : SingleResultSpecification<DeliveryNote>
|
||||
{
|
||||
public GetDeliveryNoteByIdWithProductsSpec(int deliveryNoteId)
|
||||
{
|
||||
Query
|
||||
.Where(d => d.Id == deliveryNoteId)
|
||||
.Include(d => d.ProductDeliveries!)
|
||||
.ThenInclude(dp => dp.Product);
|
||||
.Where(x => x.Id == deliveryNoteId)
|
||||
.Include(x => x.ProductDeliveries!)
|
||||
.ThenInclude(p => p.Product);
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,11 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.Prices;
|
||||
|
||||
public sealed class GetPriceByProductIdAndSupplierIdSpec : Specification<Price>
|
||||
public sealed class GetPriceByProductIdAndSupplierIdSpec : SingleResultSpecification<Price>
|
||||
{
|
||||
public GetPriceByProductIdAndSupplierIdSpec(int? productId, int? supplierId)
|
||||
{
|
||||
Query
|
||||
.Where(p => p.ProductId == productId && p.SupplierId == supplierId);
|
||||
.Where(x => x.ProductId == productId && x.SupplierId == supplierId);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.Products;
|
||||
|
||||
public sealed class GetProductByIdSpec : Specification<Product>
|
||||
public sealed class GetProductByIdSpec : SingleResultSpecification<Product>
|
||||
{
|
||||
public GetProductByIdSpec(int? productId)
|
||||
public GetProductByIdSpec(int productId)
|
||||
{
|
||||
Query
|
||||
.Where(p => p.Id == productId)
|
||||
|
||||
@@ -9,6 +9,6 @@ public sealed class GetProductsUnderLimitSpec : Specification<Product>
|
||||
{
|
||||
Query
|
||||
.Include(p => p.QuotationProducts)
|
||||
.Where(p => p.QuotationProducts.Any(q => q.Quantity < p.MinimalQuantity));
|
||||
.Where(p => p.QuotationProducts != null && p.QuotationProducts.Any(q => q.Quantity < p.MinimalQuantity));
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,13 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.PurchaseOrders;
|
||||
|
||||
public sealed class GetPurchaseOrderByIdSpec : Specification<PurchaseOrder>
|
||||
public sealed class GetPurchaseOrderByIdSpec : SingleResultSpecification<PurchaseOrder>
|
||||
{
|
||||
public GetPurchaseOrderByIdSpec(int purchaseOrderId)
|
||||
{
|
||||
Query
|
||||
.Include(po => po.PurchaseProducts)
|
||||
.Where(po => po.Id == purchaseOrderId);
|
||||
.Include(x => x.PurchaseProducts!)
|
||||
.ThenInclude(x => x.Product)
|
||||
.Where(x => x.Id == purchaseOrderId);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,14 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.PurchaseOrders;
|
||||
|
||||
public class GetPurchaseOrderByIdWithProductsSpec : Specification<PurchaseOrder>
|
||||
public class GetPurchaseOrderByIdWithProductsSpec : SingleResultSpecification<PurchaseOrder>
|
||||
{
|
||||
public GetPurchaseOrderByIdWithProductsSpec(int purchaseOrderId)
|
||||
{
|
||||
Query
|
||||
.Where(p => p.Id == purchaseOrderId)
|
||||
.Include(p => p.PurchaseProducts!)
|
||||
.ThenInclude(pp => pp.Product)
|
||||
.ThenInclude(pp=> pp!.Prices);
|
||||
.Where(x => x.Id == purchaseOrderId)
|
||||
.Include(x => x.PurchaseProducts!)
|
||||
.ThenInclude(p => p.Product)
|
||||
.ThenInclude(p=> p!.Prices);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.PurchaseProducts;
|
||||
|
||||
public sealed class GetPurchaseProductByProductIdAndPurchaseOrderIdSpec : Specification<PurchaseProduct>
|
||||
public sealed class GetPurchaseProductByProductIdAndPurchaseOrderIdSpec : SingleResultSpecification<PurchaseProduct>
|
||||
{
|
||||
public GetPurchaseProductByProductIdAndPurchaseOrderIdSpec(int productId, int purchaseOrderId)
|
||||
{
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.QuotationProducts;
|
||||
|
||||
public sealed class GetQuotationProductByProductIdAndQuotationIdSpec : Specification<QuotationProduct>
|
||||
public sealed class GetQuotationProductByProductIdAndQuotationIdSpec : SingleResultSpecification<QuotationProduct>
|
||||
{
|
||||
public GetQuotationProductByProductIdAndQuotationIdSpec(int productId, int quotationId)
|
||||
{
|
||||
|
||||
@@ -3,12 +3,13 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.Quotations;
|
||||
|
||||
public sealed class GetQuotationByIdSpec : Specification<Quotation>
|
||||
public sealed class GetQuotationByIdSpec : SingleResultSpecification<Quotation>
|
||||
{
|
||||
public GetQuotationByIdSpec(int quotationId)
|
||||
{
|
||||
Query
|
||||
.Include(q => q.QuotationProducts)
|
||||
.Include(x => x.QuotationProducts!)
|
||||
.ThenInclude(x => x.Product)
|
||||
.Where(x => x.Id == quotationId);
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.Quotations;
|
||||
|
||||
public class GetQuotationByIdWithProductsSpec : Specification<Quotation>
|
||||
public class GetQuotationByIdWithProductsSpec : SingleResultSpecification<Quotation>
|
||||
{
|
||||
public GetQuotationByIdWithProductsSpec(int quotationId)
|
||||
{
|
||||
Query
|
||||
.Where(q => q.Id == quotationId)
|
||||
.Include(q => q.QuotationProducts!)
|
||||
.ThenInclude(qp => qp.Product);
|
||||
.Where(x => x.Id == quotationId)
|
||||
.Include(x => x.QuotationProducts!)
|
||||
.ThenInclude(p => p.Product);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.Settings;
|
||||
|
||||
public sealed class GetSettingByIdSpec : Specification<Setting>
|
||||
public sealed class GetSettingByIdSpec : SingleResultSpecification<Setting>
|
||||
{
|
||||
public GetSettingByIdSpec(int settingId)
|
||||
{
|
||||
|
||||
@@ -3,11 +3,13 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.Suppliers;
|
||||
|
||||
public sealed class GetSupplierByIdSpec : Specification<Supplier>
|
||||
public sealed class GetSupplierByIdSpec : SingleResultSpecification<Supplier>
|
||||
{
|
||||
public GetSupplierByIdSpec(int? supplierId)
|
||||
{
|
||||
Query
|
||||
.Include(x => x.Prices!)
|
||||
.ThenInclude(p => p.Product)
|
||||
.Where(x => x.Id == supplierId);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.Users;
|
||||
|
||||
public sealed class GetUserByIdSpec : Specification<User>
|
||||
public sealed class GetUserByIdSpec : SingleResultSpecification<User>
|
||||
{
|
||||
public GetUserByIdSpec(int userId)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.Users;
|
||||
|
||||
public sealed class GetUserByNameSpec : Specification<User>
|
||||
public sealed class GetUserByNameSpec : SingleResultSpecification<User>
|
||||
{
|
||||
public GetUserByNameSpec(string userName)
|
||||
{
|
||||
|
||||
@@ -3,11 +3,16 @@ using PyroFetes.Models;
|
||||
|
||||
namespace PyroFetes.Specifications.WarehouseProducts;
|
||||
|
||||
public sealed class GetWarehouseProductByProductIdSpec : Specification<WarehouseProduct>
|
||||
public sealed class GetWarehouseProductByProductIdSpec : SingleResultSpecification<WarehouseProduct>
|
||||
{
|
||||
public GetWarehouseProductByProductIdSpec(int productId)
|
||||
public GetWarehouseProductByProductIdSpec(int productId, int? warehouseId = null)
|
||||
{
|
||||
Query
|
||||
.Where(x => x.ProductId == productId);
|
||||
|
||||
if (warehouseId.HasValue)
|
||||
{
|
||||
Query.Where(x => x.WarehouseId == warehouseId.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user