Exemple #1
0
        private void findPotentialRecipeInDatabase(bool exclusive)
        {
            try
            {
                potentialRecipe = RecipeTableDB.SearchAvailableRecipe(new List <IngredientModel>(ob_ingredients), exclusive);

                foreach (RecipeModel recipe in potentialRecipe)
                {
                    newMeal = new Meal();

                    newMeal.Name         = recipe.Name;
                    newMeal.Instructions = recipe.Instructions;

                    tempLink = RecipeIngredLinkTableDB.GetIngredientsForRecipe(recipe.Id);

                    StringBuilder sb = new StringBuilder();
                    foreach (RecipeIngredLinkModel link in tempLink)
                    {
                        //ingredients.Add(IngredientTableDB.GetIngredient(link.IngredientId));
                        sb.Append(IngredientTableDB.GetIngredient(link.IngredientId).Name + "\n");
                    }

                    newMeal.Ingredients = sb.ToString();
                    Console.WriteLine(newMeal.Name);

                    if (newMeal != null)
                    {
                        ob_meal.Add(newMeal);
                    }
                }
            }
            catch (Exception ex)
            {
                return;
            }
        }