private void SaveExecute()
 {
     try
     {
         MessageBoxResult result = MessageBox.Show("Are you sure you want to save edits to the recipe?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (result == MessageBoxResult.Yes)
         {
             recipe.type     = selectedType;
             recipe.authorId = author.userId;
             service.AddRecipe(recipe);
             tblRecipe editedRecipe = service.AddRecipe(recipe);
             MessageBox.Show("Recipe has been edited.");
             editView.Close();
             MessageBoxResult result2 = MessageBox.Show("Do you want to change ingredients too?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
             if (result2 == MessageBoxResult.Yes)
             {
                 EditIngredients editIngredients = new EditIngredients(editedRecipe);
                 editIngredients.ShowDialog();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 2
0
 private void SaveExecute()
 {
     try
     {
         recipe.type = selectedType;
         service.AddRecipe(recipe);
         tblRecipe addedRecipe = service.AddRecipe(recipe);
         MessageBox.Show("Recipe has been added. Add ingredients for this recipe");
         addRecipe.Close();
         AddIngredients addIngredients = new AddIngredients(addedRecipe);
         addIngredients.ShowDialog();
         isUpdated = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
 public void SaveRecipeExecute()
 {
     if (IngredientList == null || IngredientList.Count == 0)
     {
         MessageBox.Show("You need to have any ingredient to save.", "Notification");
     }
     else
     {
         try
         {
             MessageBoxResult result = MessageBox.Show("Are you sure you want to save ingredients to the recipe?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
             if (result == MessageBoxResult.Yes)
             {
                 service.AddRecipe(Recipe);
                 if (Recipe.recipeId != 0)
                 {
                     //if user select item from list and then changes
                     foreach (var ingredient in IngredientList)
                     {
                         service.AddIngredient(Ingredient);
                     }
                     MessageBox.Show("Recipe is created.", "Notification", MessageBoxButton.OK);
                     editIngView.Close();
                 }
                 else
                 {
                     MessageBox.Show("Ingredients cannot be edited.", "Notification", MessageBoxButton.OK);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }