public async Task <IActionResult> Index() { CatalogPageVM model = new CatalogPageVM(await _categoryService.GetAllCategories(), await _productService.GetAllProducts()); return(View(model)); }
public async Task <IActionResult> Index(string searchText) { CatalogPageVM model; if (!string.IsNullOrWhiteSpace(searchText)) { model = new CatalogPageVM(await _categoryService.GetAllCategories(), await _productService.FindProductsByNameAndDescription(searchText)); } else { model = new CatalogPageVM(await _categoryService.GetAllCategories(), await _productService.GetAllProducts()); } return(View(model)); }