|
7 | 7 | using Ecommerce.Application.UseCases.Products.Commands.CreateReview; |
8 | 8 | using Ecommerce.Application.UseCases.Products.Commands.DeleteProduct; |
9 | 9 | using Ecommerce.Application.UseCases.Products.CreateUser.Commands; |
10 | | -using Ecommerce.Application.UseCases.Products.Queries.GetAllProducts; |
| 10 | +using Ecommerce.Application.UseCases.Products.Queries.GetAllProductsWithoutSellerListing; |
11 | 11 | using Ecommerce.Application.UseCases.Products.Queries.GetCategories; |
12 | 12 | using Ecommerce.Application.UseCases.Products.Queries.GetFilteredProducts; |
13 | 13 | using Ecommerce.Application.UseCases.Products.Queries.GetProductBySlug; |
@@ -57,18 +57,34 @@ [FromForm] CreateProductRequest createProductRequest |
57 | 57 |
|
58 | 58 | [AllowAnonymous] |
59 | 59 | [HttpGet] |
60 | | - public async Task<IActionResult> GetProducts([FromQuery] PaginationParams paginationParams) |
| 60 | + public async Task<IActionResult> GetProducts( |
| 61 | + [FromQuery] PaginationParams paginationParams, |
| 62 | + [FromQuery] FilterProductsQuery? filterBy = null |
| 63 | + ) |
61 | 64 | { |
62 | 65 | var result = await _mediator.Send( |
63 | | - new GetAllProductsQuery(paginationParams.PageNumber, paginationParams.PageSize) |
| 66 | + new GetAllProductsWithoutSellerListingQuery() |
| 67 | + { |
| 68 | + FilterQuery = filterBy is null |
| 69 | + ? filterBy |
| 70 | + : filterBy with |
| 71 | + { |
| 72 | + PaginationParameters = new PaginationParameters |
| 73 | + { |
| 74 | + PageNumber = paginationParams.PageNumber, |
| 75 | + PageSize = paginationParams.PageSize, |
| 76 | + }, |
| 77 | + }, |
| 78 | + } |
64 | 79 | ); |
65 | 80 |
|
66 | 81 | if (result.IsFailed) |
67 | 82 | { |
68 | 83 | _logger.LogError("Failed to get all products: {@result}", result); |
69 | 84 | return new ObjectResult(result); |
70 | 85 | } |
71 | | - |
| 86 | + Response.Headers.Add("X-Data-Source", result.Value.DataSourceType.ToString()); |
| 87 | + Response.Headers.Add("X-Data-SourceId", result.Value.DataSourceId.ToString()); |
72 | 88 | return Ok(result.Value); |
73 | 89 | } |
74 | 90 |
|
|
0 commit comments