public IActionResult List(string categoryName) { var candyListViewModel = new CandyListViewModel(); if (string.IsNullOrEmpty(categoryName)) { candyListViewModel.Candies = _candyRepository.GetAllCandy; candyListViewModel.CurrentCategory = "All candies"; } else { candyListViewModel.Candies = _candyRepository.GetCandiesByCategory(categoryName).ToList(); candyListViewModel.CurrentCategory = _categoryRepository.GetCategoryByName(categoryName)?.CategoryName; } return(View(candyListViewModel)); }