internal static IEnumerable<ProductSearchResult> Build(ProductGetAllResponse response, string query)
    {
      if(response.Body.ProductGetAllResult != null)
      {
        return response.Body.ProductGetAllResult.Products.Select(p => new ProductSearchResult
        {
          Name = p.Name
        });
      }

      return new ProductSearchResult[0];
    }
Example #2
0
        public async Task <ProductGetAllResponse> AllProducts([FromQuery] ProductQueryParameter productQueryParameter)
        {
            var result = await _mediator.Send(new ProductQuery()
            {
                PageIndex      = productQueryParameter.PageIndex,
                RecordsPerPage = productQueryParameter.RecordsPerPage
            });

            var response = new ProductGetAllResponse();

            response.PageIndex      = productQueryParameter.PageIndex;
            response.RecordsPerPage = productQueryParameter.RecordsPerPage;
            response.TotalItems     = result.TotalItems;
            response.Items          = result.Products.Select(_mapper.Map <ProductResponseItem>).ToList();
            return(response);
        }