Exemplo n.º 1
0
 public async Task <IActionResult> SearchCocktails(SearchCocktailViewModel viewModel)
 {
     if (viewModel.AvgRating != null)
     {
         viewModel.SearchResults = (await _cocktailServices.SearchByMultipleCriteriaAsync(viewModel.Name, viewModel.Ingredient, viewModel.IncludeOnlyAlcoholicDrinks)).Select(c => c.MapToViewModel()).Where(b => b.Rating == viewModel.AvgRating).ToList();
     }
     else
     {
         viewModel.SearchResults = (await _cocktailServices.SearchByMultipleCriteriaAsync(viewModel.Name, viewModel.Ingredient, viewModel.IncludeOnlyAlcoholicDrinks)).Select(c => c.MapToViewModel()).ToList();
     }
     return(View(viewModel));
 }