public async Task <ActionResult> List(ProductsListVM productsList, uint page) { productsList ??= new ProductsListVM(); productsList.Filters ??= new ProductsFiltersVM(); var productsTask = _productManager.Products(new ProductsFiltersDTO { Brand = productsList.Filters.Brand, Category = productsList.Filters.Category, Country = productsList.Filters.Country, Name = productsList.Filters.Name, Price = productsList.Filters.Price, Removed = productsList.Filters.Removed, Weight = productsList.Filters.Weight, PageSize = PageSize, Page = page }); var brandTask = _productManager.Brands(); var categorTask = _productManager.Categories(); var countryTask = _productManager.Countries(); await Task.WhenAll(productsTask, brandTask, categorTask, countryTask); var productsListDTO = await productsTask; productsList.Brands = new SelectList((await brandTask).Select(b => b.Name)); productsList.Categories = new SelectList((await categorTask).Select(c => c.Name)); productsList.Countries = new SelectList((await countryTask).Select(c => c.Name)); productsList.Products = productsListDTO.Products.Select(p => new ProductDataVM { Id = p.Id, Brand = p.Brand?.Name, Category = p.Category?.Name, Country = p.Country.Name, Name = p.Name, Price = p.Price, Removed = p.Removed, Weight = p.Weight }); productsList.PagingInfo = new PagingInfoVM { CurrentPage = productsListDTO.PagingInfo.CurrentPage, TotalItems = productsListDTO.PagingInfo.CurrentPage, ItemsPerPage = PageSize }; return(View(productsList)); }