/// <summary> /// Executes the add ingredient amount command /// </summary> private void AddItemExecute() { try { AddIngredientAmountToRecipe addIngredientWindow = new AddIngredientAmountToRecipe(Ingredient, recipeID); addIngredientWindow.ShowDialog(); // Refresh the list IngrediantAmountList = recipeData.GetAllSelectedRecipeIngrediantAmount(RecipeID); IngrediantAmountListCount = IngrediantAmountList.Count(); if (IngrediantAmountList.Count > 0) { addIngredientToRecipe.gridIngredientItem.Visibility = Visibility.Visible; addIngredientToRecipe.msgNoItems.Visibility = Visibility.Collapsed; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// Method for deleting the selected item from the list /// </summary> public void DeleteExecute() { tblIngredient ing = ingrediantsData.FindIngredient(ItemAmount.IngredientID); try { MessageBoxResult dialogDelete = Xceed.Wpf.Toolkit.MessageBox.Show($"Da li zelite da obrisete ovaj sastojak iz liste?\n\nSastojak: {ing.IngredientName}", "Obrisi sastojak", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (dialogDelete == MessageBoxResult.Yes) { if (ItemAmount != null) { recipeData.DeleteIngredientAmount(ItemAmount.IngredientAmountID); IngrediantAmountList = recipeData.GetAllSelectedRecipeIngrediantAmount(RecipeID); IngrediantAmountListCount = IngrediantAmountList.Count(); } } } catch (Exception) { MessageBoxResult dialog = Xceed.Wpf.Toolkit.MessageBox.Show("Trenutno je nemoguce obrisati sastojak...", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }