From b1a0a4120202a5fa224d4bc12dd8d91434336fc0 Mon Sep 17 00:00:00 2001 From: Francesco Lorenzo D'Amico Date: Tue, 20 May 2025 16:05:03 +0200 Subject: [PATCH] Add Methodf to get all Shoopinglists on endpoint of the Detail Site of Shoppinglist --- .../Controller/ShoppingList/ShoppingListController.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Francesco.Recipes.World/Controller/ShoppingList/ShoppingListController.cs b/Francesco.Recipes.World/Controller/ShoppingList/ShoppingListController.cs index 8fe8fca..7557edd 100644 --- a/Francesco.Recipes.World/Controller/ShoppingList/ShoppingListController.cs +++ b/Francesco.Recipes.World/Controller/ShoppingList/ShoppingListController.cs @@ -60,10 +60,15 @@ return NotFound(); } + var recipeInAnyShoppingList = (await _shoppingListRepository.GetAllShoppingListsAsync()) + .SelectMany(sl => sl.RecipeShoppingList.Select(rsl => rsl.Recipe)) + .ToList(); + var viewModel = new ShoppingListDetailsViewModel { ShoppingList = shoppingList, RecipeCount = recipeCount, + RecipesInAnyShoppingList = recipeInAnyShoppingList, }; return View(viewModel);