public ActionResult ApplyFilter(string searchProductName) { List <Product> productsList; if (searchProductName != null) { productsList = _productsRepo.GetProductsSearchName(searchProductName); } else { productsList = _productsRepo.GetProductsList(); } GetCategoriesNameList(productsList[0]); return(View("ViewProduct", productsList)); }