public void DeleteExecute() { try { if (Recipe != null) { MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this recipe?", "Confirmation", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { bool isDeleted = recipes.DeleteRecipe(Recipe); if (isDeleted == true) { MessageBox.Show("Recipe is deleted.", "Notification", MessageBoxButton.OK); RecipeList = recipes.ViewAllRecipes(); AdminView newAdminView = new AdminView(); adminView.Close(); newAdminView.ShowDialog(); } else { MessageBox.Show("Recipe cannot be deleted.", "Notification", MessageBoxButton.OK); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// This method invokes method for deleting order. /// </summary> public void CancelRecipeExecute() { try { MessageBoxResult result = MessageBox.Show("Are you sure you want to cancel creating the recipe?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { bool isCanceled = recipes.DeleteRecipe(Recipe); if (isCanceled == true) { MessageBox.Show("Creating recipe is canceled.", "Notification", MessageBoxButton.OK); if (recipe.Author == "Administrator") { AdminView adminView = new AdminView(); addIngredients.Close(); adminView.ShowDialog(); } else { UserView userView = new UserView(users.FindUser(recipe.UserId)); addIngredients.Close(); userView.ShowDialog(); } } else { MessageBox.Show("Creating recipe cannot be canceled.", "Notification", MessageBoxButton.OK); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }