diff --git a/Francesco.Recipes.World/Repositories/ShoppingList/IShoppingListRepository.cs b/Francesco.Recipes.World/Repositories/ShoppingList/IShoppingListRepository.cs index c14f0aa..3b30be5 100644 --- a/Francesco.Recipes.World/Repositories/ShoppingList/IShoppingListRepository.cs +++ b/Francesco.Recipes.World/Repositories/ShoppingList/IShoppingListRepository.cs @@ -18,6 +18,8 @@ Task GetRecipeByNameAndImageAsync(string recipeName, string imageFileName); + Task GetByIdAsync(Guid shoppingListId); + Task CountAllRecipeShoppinglistsAsync(); } } diff --git a/Francesco.Recipes.World/Repositories/ShoppingList/ShoppingListRepository.cs b/Francesco.Recipes.World/Repositories/ShoppingList/ShoppingListRepository.cs index 1e64469..f49bfce 100644 --- a/Francesco.Recipes.World/Repositories/ShoppingList/ShoppingListRepository.cs +++ b/Francesco.Recipes.World/Repositories/ShoppingList/ShoppingListRepository.cs @@ -109,6 +109,22 @@ return shoppingList; } + public async Task GetByIdAsync(Guid shoppingListId) + { + return await _context.ShoppingLists + .Include(sl => sl.RecipeShoppingList) + .ThenInclude(rsl => rsl.Recipe) + .Include(sl => sl.RecipeShoppingList) + .ThenInclude(rsl => rsl.SelectedIngredients) + .ThenInclude(si => si.RecipeIngredient) + .ThenInclude(ri => ri.Ingredient) + .Include(sl => sl.RecipeShoppingList) + .ThenInclude(rsl => rsl.SelectedIngredients) + .ThenInclude(si => si.RecipeIngredient) + .ThenInclude(ri => ri.Unit) + .FirstOrDefaultAsync(sl => sl.Id == shoppingListId); + } + public async Task> GetIngredientsOfRecipeInListAsync(Guid shoppingListRecipeId) { return await _context.RecipeIngredientsShoppingLists