Example #1
0
        private async Task <List <WeightedRecipies> > GetRelevantRecpies(List <string> ProductRefrence)
        {
            RecipeHandling recipeHandling = new RecipeHandling();
            Dictionary <Recipe, Dictionary <Ingredient, List <string> > > dict = new Dictionary <Recipe, Dictionary <Ingredient, List <string> > >();
            List <Recipe> recipes = new List <Recipe>();

            foreach (string refs in ProductRefrence)
            {
                recipes.AddRange(await recipeHandling.GetReferencesAsync(new List <string>()
                {
                    refs
                }));
            }



            foreach (Recipe r in recipes)
            {
                foreach (Ingredient I in r._ingredientList)
                {
                    foreach (List <string> sList in allRefs)
                    {
                        foreach (string s in sList)
                        {
                            if (I._ingredientName.Contains(s))
                            {
                                if (dict.ContainsKey(r))
                                {
                                    if (dict[r].ContainsKey(I))
                                    {
                                        dict[r][I].Add(s);
                                    }
                                    else
                                    {
                                        dict[r].Add(I, new List <string> {
                                            s
                                        });
                                    }
                                }
                                else
                                {
                                    dict.Add(r, new Dictionary <Ingredient, List <string> >()
                                    {
                                        { I, new List <string> {
                                              s
                                          } }
                                    });
                                }
                            }
                        }
                    }
                }
            }
            return(NewGeneratWeighted(dict));
        }
Example #2
0
 public RecipeViewController(UserContext context)
 {
     //_context = context;
     recipeHandling = new RecipeHandling(context);
 }