Exemple #1
0
        /// <summary>
        /// Method for edit the selected item from the list
        /// </summary>
        public void EditRecipeExecute()
        {
            tblRecipe tempRecipe = new tblRecipe
            {
                RecipeID          = 0,
                RecipeName        = Recipe.RecipeName,
                RecipeType        = Recipe.RecipeType,
                NoPeople          = Recipe.NoPeople,
                RecipeDescription = Recipe.RecipeDescription,
                CreationDate      = Recipe.CreationDate,
                UserID            = Recipe.UserID,
                Changed           = Recipe.Changed
            };

            List <tblIngredientAmount> tempRecipeIngrediantAmountList = recipeData.GetAllSelectedRecipeIngrediantAmount(recipe.RecipeID).ToList();

            try
            {
                MessageBoxResult dialogDelete = Xceed.Wpf.Toolkit.MessageBox.Show($"Da li zelite da azurirate ovaj recept iz liste?\n\nRecept: {Recipe.RecipeName}", "Azuriraj recept", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                if (dialogDelete == MessageBoxResult.Yes)
                {
                    if (Recipe != null)
                    {
                        AddRecipe addRecipeWindow = new AddRecipe(Recipe);
                        addRecipeWindow.ShowDialog();

                        // Checks if the recipe did not get updated
                        if (isRecipeNotUpdated == true)
                        {
                            recipeData.AddRecipe(tempRecipe);
                            for (int i = 0; i < tempRecipeIngrediantAmountList.Count; i++)
                            {
                                tempRecipeIngrediantAmountList[i].IngredientAmountID = 0;
                                tempRecipeIngrediantAmountList[i].RecipeID           = tempRecipe.RecipeID;
                                recipeData.AddIngredientAmount(tempRecipeIngrediantAmountList[i]);
                            }
                            isRecipeNotUpdated = false;
                        }
                        else
                        {
                            // Save recipe changes
                            recipeData.AddRecipe(Recipe);
                        }

                        RecipeList = recipeData.GetAllRecipes().ToList();
                        allReciperWindow.DataGridOrder.ItemsSource = RecipeList;
                        AllRecipesWindow.filteredList    = new List <tblRecipe>();
                        allReciperWindow.filteredRecipes = new List <tblRecipe>();
                    }
                }
            }
            catch (Exception)
            {
                MessageBoxResult dialog = Xceed.Wpf.Toolkit.MessageBox.Show("Trenutno je nemoguce obrisati recept...", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #2
0
 /// <summary>
 /// Method for adding the selected item from the list
 /// </summary>
 public void AddRecipeExecute()
 {
     try
     {
         AddRecipe addRecipeWindow = new AddRecipe();
         addRecipeWindow.ShowDialog();
         RecipeList = recipeData.GetAllRecipes().ToList();
         allReciperWindow.DataGridOrder.ItemsSource = RecipeList;
         AllRecipesWindow.filteredList    = new List <tblRecipe>();
         allReciperWindow.filteredRecipes = new List <tblRecipe>();
     }
     catch (Exception)
     {
         MessageBoxResult dialog = Xceed.Wpf.Toolkit.MessageBox.Show("Trenutno je nemoguce dodati recept...", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 private void AddRecipeExecute()
 {
     try
     {
         AddRecipe addView = new AddRecipe(currentUser);
         addView.ShowDialog();
         if ((addView.DataContext as AddRecipeViewModel).isUpdated == true)
         {
             RecipeList    = service.GetAllRecipes();
             selectedTitle = null;
             selectedType  = null;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }