Beispiel #1
0
        /*
         * Adds a new ingredient to the ingredient list for this recipe
         * that's being added or edited in this form.
         */
        private async void addIngredient(object sender, RoutedEventArgs e)
        {
            IngredientDialog ingredientDialog = new IngredientDialog();
            await ingredientDialog.ShowAsync();

            if (ingredientDialog.NewIngredient != null)
            {
                RecipeIngredient newIngredient = ingredientDialog.NewIngredient;
                this.ingredients.Add(newIngredient);
            }
        }
Beispiel #2
0
        private async void editIngredient(object sender, RoutedEventArgs e)
        {
            RecipeIngredient ingredientToEdit = (RecipeIngredient)((MenuFlyoutItem)e.OriginalSource).DataContext;
            int ingredientIndex = ingredients.IndexOf(ingredientToEdit);
            IngredientDialog ingredientDialog = new IngredientDialog(ingredientToEdit);
            await ingredientDialog.ShowAsync();

            RecipeIngredient updatedIngredient = ingredientDialog.NewIngredient;

            if (updatedIngredient != null)
            {
                this.ingredients[ingredientIndex] = updatedIngredient;
            }
        }