feat(sorting): implement ApplyOrderWithInStockPriority method for enhanced product sorting
Build and Deploy to Kubernetes / build-and-deploy (push) Has been cancelled

- Added ApplyOrderWithInStockPriority method to prioritize in-stock products in queries.
- Updated GetDiscountProductsQueryHandler and GetCustomerProductsByFilterQueryHandler to utilize the new sorting method, ensuring in-stock items are listed first followed by user-defined sorting or creation date.
- Improved overall query handling for product availability and sorting logic.
This commit is contained in:
masoodafar-web
2026-07-26 00:17:44 +03:30
parent d232399f43
commit ce98efdd68
3 changed files with 20 additions and 9 deletions
@@ -57,10 +57,8 @@ public class GetDiscountProductsQueryHandler : IRequestHandler<GetDiscountProduc
query = query.Where(p => p.Price <= request.MaxPrice.Value);
}
if (!string.IsNullOrEmpty(request.SortBy))
query = query.ApplyOrder(request.SortBy);
else
query = query.OrderByDescending(p => p.Created);
// موجودی‌دارها اول، سپس سورت درخواستی
query = query.ApplyOrderWithInStockPriority(request.SortBy, p => p.RemainingCount > 0);
var totalCount = await query.CountAsync(cancellationToken);