コード例 #1
0
        public async Task <ActionResult <SearchResultsVM> > Search(string query, uint page)
        {
            ProductsListDTO productsListDto = await _catalogManager.SearchByNameOrDescription(new CatalogSearchDTO
            {
                Page              = page,
                PageSize          = PageSize,
                NameOrDescription = query
            });

            return(View(new SearchResultsVM
            {
                Products = productsListDto.Products.Select(p => new ProductShortVM
                {
                    Id = p.Id,
                    Brand = p.Brand?.Name,
                    Country = p.Country?.Name,
                    Image = p.Image,
                    Name = p.Name,
                    Price = p.Price,
                    Weight = p.Weight
                }),
                PagingInfo = new PagingInfoVM
                {
                    CurrentPage = productsListDto.PagingInfo.CurrentPage,
                    TotalItems = productsListDto.PagingInfo.TotalItems,
                    ItemsPerPage = productsListDto.PagingInfo.ItemsPerPage
                }
            }));
        }