using Endpoint; using Models; using System.Collections.Immutable; namespace LocalEndpoint { internal class RecipesService : IRecipesService { private readonly Dictionary accountsRecipes = new Dictionary(); public List PopularRecipes() { return new List { new RecipeInfo("Chicken Curry", 500, 45, new Uri("https://cdn.chefclub.tools/uploads/recipes/cover-thumbnail/f287b191-dc8e-4c85-bbb6-e26387c354d3.jpg"), 3, Guid.NewGuid()), new RecipeInfo("Spaghetti Bolognese", 1000, 30, new Uri("https://media.istockphoto.com/id/1144823591/fr/photo/spaghetti-dans-un-plat-sur-un-fond-blanc.jpg?s=612x612&w=0&k=20&c=qFzd8iE185mpsX7hWqYaieOWlzJVCkzFdYsxmwUT3-Q="), 1, Guid.NewGuid()), new RecipeInfo("Beef Stroganoff", 100, 10, new Uri("https://www.cookwithnabeela.com/wp-content/uploads/2023/02/BeefStroganoff.webp"), 5, Guid.NewGuid()), new RecipeInfo("Fish And Ships", 450, 15, new Uri("https://upload.wikimedia.org/wikipedia/commons/f/ff/Fish_and_chips_blackpool.jpg"), 4, Guid.NewGuid()), new RecipeInfo("Caesar Salad", 150, 20, new Uri("https://www.galbani.fr/wp-content/uploads/2020/04/AdobeStock_157570276-2.jpeg"), 1, Guid.NewGuid()) }; } public Recipe GetRecipe(RecipeInfo info) { User owner = new User(new Uri("https://i.ibb.co/L6t6bGR/DALL-E-2023-05-10-20-27-31-cook-looking-at-the-camera-with-a-chef-s-hat-laughing-in-an-exaggerated-w.png"), "The Funny Chief"); var ingredients = new List { new Ingredient("Banana", 12), new Ingredient("Apple", 2) }.ToImmutableList(); var steps = new List { new PreparationStep("Step 1", "This step is an hardcoded step from a stub implementation of IRecipesSeervice") }.ToImmutableList(); return new Recipe(info, owner, ingredients, steps); } public IAccountRecipes GetRecipesOf(Account account) { IAccountRecipes? recipes; accountsRecipes.TryGetValue(account, out recipes); if (recipes == null) { recipes = new AccountRecipes(account); recipes.UploadRecipe(new Recipe(new RecipeInfo("Cupcake", 500, 12, new Uri("https://www.mycake.fr/wp-content/uploads/2015/12/rs_cupcake_4x3.jpg"), 4.2F, Guid.NewGuid()), account.User, new List { new Ingredient("Chocolate", 4) }.ToImmutableList(), new List { new PreparationStep("Eat Chocolate", "Eat the chocolate") }.ToImmutableList())); accountsRecipes.Add(account, recipes); } return recipes; } } }