@ -1,66 +1,45 @@
using Endpoint ;
using Endpoint ;
using Models ;
using Models ;
using System.Collections.Immutable ;
namespace LocalEndpoint
namespace LocalEndpoint
{
{
internal class RecipesService : IRecipesService
internal class RecipesService : IRecipesService
{
{
private readonly Dictionary < Account , IAccountRecipes > accountsRecipes = new Dictionary < Account , IAccountRecipes > ( ) ;
public List < RecipeInfo > PopularRecipes ( )
public List < RecipeInfo > PopularRecipes ( )
{
{
return new List < RecipeInfo > {
return new List < RecipeInfo > {
new RecipeInfo ( "Chicken Curry" , 500 , 45 , new Uri ( "https://cdn.chefclub.tools/uploads/recipes/cover-thumbnail/f287b191-dc8e-4c85-bbb6-e26387c354d3.jpg" ) , 3 ),
new RecipeInfo ( "Chicken Curry" , 500 , 45 , new Uri ( "https://cdn.chefclub.tools/uploads/recipes/cover-thumbnail/f287b191-dc8e-4c85-bbb6-e26387c354d3.jpg" ) , 3 , new Guid ( ) ),
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 ),
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 , new Guid ( ) ),
new RecipeInfo ( "Beef Stroganoff" , 100 , 10 , new Uri ( "https://www.cookwithnabeela.com/wp-content/uploads/2023/02/BeefStroganoff.webp" ) , 5 ),
new RecipeInfo ( "Beef Stroganoff" , 100 , 10 , new Uri ( "https://www.cookwithnabeela.com/wp-content/uploads/2023/02/BeefStroganoff.webp" ) , 5 , new Guid ( ) ),
new RecipeInfo ( "Fish And Ships" , 450 , 15 , new Uri ( "https://upload.wikimedia.org/wikipedia/commons/f/ff/Fish_and_chips_blackpool.jpg" ) , 4 ),
new RecipeInfo ( "Fish And Ships" , 450 , 15 , new Uri ( "https://upload.wikimedia.org/wikipedia/commons/f/ff/Fish_and_chips_blackpool.jpg" ) , 4 , new Guid ( ) ),
new RecipeInfo ( "Caesar Salad" , 150 , 20 , new Uri ( "https://www.galbani.fr/wp-content/uploads/2020/04/AdobeStock_157570276-2.jpeg" ) , 1 )
new RecipeInfo ( "Caesar Salad" , 150 , 20 , new Uri ( "https://www.galbani.fr/wp-content/uploads/2020/04/AdobeStock_157570276-2.jpeg" ) , 1 , new Guid ( ) )
} ;
} ;
}
}
public Recipe GetRecipe ( RecipeInfo info )
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" ) ;
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" ) ;
List < Ingredient > ingredients = new List < Ingredient > { new Ingredient ( "Banana" , 12 ) , new Ingredient ( "Apple" , 2 ) } ;
var ingredients = new List < Ingredient > { new Ingredient ( "Banana" , 12 ) , new Ingredient ( "Apple" , 2 ) } . ToImmutableList ( ) ;
List < PreparationStep > steps = new List < PreparationStep > { new PreparationStep ( "Step 1" , "This step is an hardcoded step from a stub implementation of IRecipesSeervice" ) } ;
var steps = new List < PreparationStep > { new PreparationStep ( "Step 1" , "This step is an hardcoded step from a stub implementation of IRecipesSeervice" ) } . ToImmutableList ( ) ;
return new Recipe ( info , owner , ingredients , steps ) ;
return new Recipe ( info , owner , ingredients , steps ) ;
}
}
public List < RecipeInfo > RecommendedRecipesOf ( Account account )
public IAccountRecipes GetRecipesOf ( Account account )
{
return new List < RecipeInfo > {
new RecipeInfo ( "Chicken Salad" , 500 , 20 , new Uri ( "https://healthyfitnessmeals.com/wp-content/uploads/2021/04/Southwest-chicken-salad-7-500x500.jpg" ) , 4 ) ,
new RecipeInfo ( "Chocolate Cake" , 2500 , 10 , new Uri ( "https://bakewithshivesh.com/wp-content/uploads/2022/08/IMG_0248-scaled.jpg" ) , 3 ) ,
new RecipeInfo ( "Salmon" , 20 , 10 , new Uri ( "https://www.wholesomeyum.com/wp-content/uploads/2021/06/wholesomeyum-Pan-Seared-Salmon-Recipe-13.jpg" ) , 4 ) ,
new RecipeInfo ( "Fish" , 50 , 30 , new Uri ( "https://www.ciaanet.org/wp-content/uploads/2022/07/Atlantic-and-Pacific-whole-salmon-1024x683.jpg" ) , 4.5F ) ,
new RecipeInfo ( "Space Cake" , 800 , 5 , new Uri ( "https://static.youmiam.com/images/recipe/1500x1000/space-cake-22706?placeholder=web_recipe&sig=f14a7a86da837c6b8cc678cde424d6d5902f99ec&v3" ) , 5 )
} ;
}
public List < RecipeInfo > LookupFavoritesOf ( Account account )
{
return new List < RecipeInfo > {
new RecipeInfo ( "Chicken Salad" , 500 , 20 , new Uri ( "https://healthyfitnessmeals.com/wp-content/uploads/2021/04/Southwest-chicken-salad-7-500x500.jpg" ) , 4 ) ,
new RecipeInfo ( "Space Cake" , 800 , 5 , new Uri ( "https://static.youmiam.com/images/recipe/1500x1000/space-cake-22706?placeholder=web_recipe&sig=f14a7a86da837c6b8cc678cde424d6d5902f99ec&v3" ) , 5 ) ,
new RecipeInfo ( "Fish And Ships" , 450 , 15 , new Uri ( "https://upload.wikimedia.org/wikipedia/commons/f/ff/Fish_and_chips_blackpool.jpg" ) , 4 ) ,
new RecipeInfo ( "Caesar Salad" , 150 , 20 , new Uri ( "https://www.galbani.fr/wp-content/uploads/2020/04/AdobeStock_157570276-2.jpeg" ) , 1 )
} ;
}
public List < ( RecipeInfo , uint ) > LookupWeeklyListOf ( Account account )
{
return new List < ( RecipeInfo , uint ) > {
( new RecipeInfo ( "Space Cake" , 800 , 5 , new Uri ( "https://static.youmiam.com/images/recipe/1500x1000/space-cake-22706?placeholder=web_recipe&sig=f14a7a86da837c6b8cc678cde424d6d5902f99ec&v3" ) , 5 ) , 4 ) ,
( new RecipeInfo ( "Chicken Curry" , 500 , 45 , new Uri ( "https://cdn.chefclub.tools/uploads/recipes/cover-thumbnail/f287b191-dc8e-4c85-bbb6-e26387c354d3.jpg" ) , 3 ) , 4 ) ,
( 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 ) , 1 ) ,
} ;
}
public AccountRecipeRate GetRateOf ( Account account , Recipe recipe )
{
{
Random random = new Random ( ) ;
IAccountRecipes ? recipes ;
return new AccountRecipeRate ( random . Next ( ) % 2 = = 0 , ( uint ) random . Next ( 0 , 6 ) ) ;
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 , new Guid ( ) ) , account . User , new List < Ingredient > { new Ingredient ( "Chocolate" , 4 ) } . ToImmutableList ( ) , new List < PreparationStep > { new PreparationStep ( "Eat Chocolate" , "Eat the chocolate" ) } . ToImmutableList ( ) ) ) ;
accountsRecipes . Add ( account , recipes ) ;
}
return recipes ;
}
}