feat(discount): add InStock filter to discount product queries and mappings
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled
- Introduced InStock property to GetDiscountProductsQuery and GetCustomerProductsByFilterQuery for filtering based on product availability. - Updated query handlers to apply InStock filtering logic in both discount and customer product queries. - Enhanced mapping configurations to include InStock in the response DTOs. - Bumped Protobuf project version to reflect the addition of new features.
This commit is contained in:
+4
@@ -8,6 +8,10 @@ public class GetDiscountProductsQuery : IRequest<GetDiscountProductsResponseDto>
|
||||
public PaginationState? PaginationQuery { get; set; }
|
||||
public long? CategoryId { get; set; }
|
||||
public string? SearchTerm { get; set; }
|
||||
/// <summary>
|
||||
/// true = فقط موجود (RemainingCount > 0)، false = فقط ناموجود
|
||||
/// </summary>
|
||||
public bool? InStock { get; set; }
|
||||
public bool? IsActive { get; set; }
|
||||
public int? MinPrice { get; set; }
|
||||
public int? MaxPrice { get; set; }
|
||||
|
||||
+5
@@ -42,6 +42,11 @@ public class GetDiscountProductsQueryHandler : IRequestHandler<GetDiscountProduc
|
||||
query = query.Where(p => p.IsActive == request.IsActive.Value);
|
||||
}
|
||||
|
||||
if (request.InStock == true)
|
||||
query = query.Where(p => p.RemainingCount > 0);
|
||||
else if (request.InStock == false)
|
||||
query = query.Where(p => p.RemainingCount <= 0);
|
||||
|
||||
if (request.MinPrice.HasValue)
|
||||
{
|
||||
query = query.Where(p => p.Price >= request.MinPrice.Value);
|
||||
|
||||
+4
@@ -21,6 +21,10 @@ public class GetCustomerProductsByFilterQuery : IRequest<GetCustomerProductsByFi
|
||||
public int? SaleCount { get; set; }
|
||||
public int? ViewCount { get; set; }
|
||||
public int? RemainingCount { get; set; }
|
||||
/// <summary>
|
||||
/// true = فقط موجود (RemainingCount > 0)، false = فقط ناموجود
|
||||
/// </summary>
|
||||
public bool? InStock { get; set; }
|
||||
public bool? IsActive { get; set; }
|
||||
public List<long>? CategoryIds { get; set; }
|
||||
}
|
||||
|
||||
+5
@@ -56,6 +56,11 @@ public class GetCustomerProductsByFilterQueryHandler : IRequestHandler<GetCustom
|
||||
if (request.RemainingCount.HasValue)
|
||||
query = query.Where(x => x.RemainingCount == request.RemainingCount.Value);
|
||||
|
||||
if (request.InStock == true)
|
||||
query = query.Where(x => x.RemainingCount > 0);
|
||||
else if (request.InStock == false)
|
||||
query = query.Where(x => x.RemainingCount <= 0);
|
||||
|
||||
if (request.CategoryIds != null && request.CategoryIds.Any())
|
||||
query = query.Where(x => x.ProductCategories.Any(pc => request.CategoryIds.Contains(pc.CategoryId)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user