public IActionResult Search(string searchQuery) { if (string.IsNullOrWhiteSpace(searchQuery) || string.IsNullOrEmpty(searchQuery)) { return(RedirectToAction("Index")); } var searchedFoods = _foodService.GetFilteredFoods(searchQuery); var model = _mapper.FoodsToHomeIndexModel(searchedFoods); return(View(model)); }
public IActionResult Topic(int id, string searchQuery) { var category = _categoryService.GetById(id); var foods = _foodService.GetFilteredFoods(id, searchQuery); var foodListings = foods.Select(food => new FoodListingModel { Id = food.Id, Name = food.Name, InStock = food.InStock, Price = food.Price, ShortDescription = food.ShortDescription, Category = _mapper.FoodToCategoryListing(food), ImageUrl = food.ImageUrl }); var model = new CategoryTopicModel { Category = _mapper.CategoryToCategoryListing(category), Foods = foodListings }; return(View(model)); }