Esempio n. 1
0
        public async Task <IActionResult> Index()
        {
            CatalogPageVM model = new CatalogPageVM(await _categoryService.GetAllCategories(),
                                                    await _productService.GetAllProducts());

            return(View(model));
        }
Esempio n. 2
0
        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));
        }