private void UpdateAvailableIngredients() { var assignedIngredients = AssignedIngredientBusinessModels.Select(i => i.IngredientId).ToList(); var availableIngredients = _allIngredients.Where(i => !assignedIngredients.Contains(i.Id)); AvailableIngredients.Clear(); foreach (var ingredient in availableIngredients) { AvailableIngredients.Add(ingredient); } }
public CreateEditRecipeDesignViewModel() { Recipe = TestData.GetTestRecipe("Test"); AvailableIngredients.Add(new Ingredient("Mehl")); AvailableIngredients.Add(new Ingredient("Milch")); AvailableIngredients.Add(new Ingredient("Butter")); AvailableIngredients.Add(new Ingredient("Eier")); AvailableIngredients.Add(new Ingredient("Salz")); AvailableIngredients.Add(new Ingredient("Zucker")); Recipe.Categories.AddRange(TestData.GetTestCategories()); SelectedIngredientIndex = 2; IngredientAmount = 80; SelectedMeasurementTypeIndex = 2; }
public List <Recipe> FilterList() { List <Recipe> outputRecipes = new List <Recipe>(); //Foreach duplicated in order to go through both RecipeList, and UserRecipeList, this seperation exists in order to create the "My recipes" tab easily. foreach (Recipe rec in RecipeList) { //Check the recipe. If the user is missing even one ingredient, then do no add it to the list. //Only if all ingredients are available will the recipe be added. bool canBeMadeWithAvailable = true; foreach (Ingredient ing in rec.Ingredients) { if (canBeMadeWithAvailable && !AvailableIngredients.Contains(ing)) { canBeMadeWithAvailable = false; } } if (canBeMadeWithAvailable) { outputRecipes.Add(rec); } } foreach (Recipe rec in UserRecipeList) { //Check the recipe. If the user is missing even one ingredient, then do no add it to the list. //Only if all ingredients are available will the recipe be added. bool canBeMadeWithAvailable = true; foreach (Ingredient ing in rec.Ingredients) { if (canBeMadeWithAvailable && !AvailableIngredients.Contains(ing)) { canBeMadeWithAvailable = false; } } if (canBeMadeWithAvailable) { outputRecipes.Add(rec); } } return(outputRecipes); }
public RecipeListDesignViewModel() { AvailableRecipes.Add(TestData.GetTestRecipe("Eierspeis")); AvailableRecipes.Add(TestData.GetTestRecipe("Schnitzel")); AvailableRecipes.Add(TestData.GetTestRecipe("Curry")); AvailableRecipes.Add(TestData.GetTestRecipe("Brathendl")); AvailableRecipes.Add(TestData.GetTestRecipe("Pancakes")); AvailableIngredients.Add(new FilterObject(TestData.GetTestIngredient("Mehl"))); AvailableIngredients.Add(new FilterObject(TestData.GetTestIngredient("Milch"))); AvailableIngredients.Add(new FilterObject(TestData.GetTestIngredient("Eier"))); SelectedIngredients.Add(AvailableIngredients[1]); SelectedIngredients.Add(AvailableIngredients[2]); AvailableCategories.AddRange(TestData.GetTestFilterCategories()); SelectedCategory = AvailableCategories[0]; SearchByRecipe = false; SearchByIngredient = true; }