private void DeleteBook(object sender, EventArgs e) { BookButton senderBtn = (BookButton)sender; string msg = $"Are you sure you want to delete {senderBtn.Content} and all its recipes"; MessageBoxResult messageBoxResult = MessageBox.Show(msg, "Delete Confirmation", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { Controller.GetInstance().DeleteBook(senderBtn.ID); this.LoadBooks(sender, e); this.ShowCreateBook(sender, e); } }
private void LoadBooks(object sender, EventArgs e) { BookPanel.Children.Clear(); foreach (ICookbook book in _controller.GetBooks()) { Button button = new BookButton(book.ID, book.Title, LoadRecipes, DeleteBook); button.Background = BookPanel.Background; BookPanel.Children.Add(button); } BookButton addButton = new BookButton(0, "New book", ShowCreateBook, LoadBooks); BookPanel.Children.Add(addButton); }
private void LoadRecipes(object sender, EventArgs e) { RecipePanel.Children.Clear(); BookButton senderButton = (BookButton)sender; _chosenBook = senderButton.ID; // Implement getRecipes and change books to that foreach (IRecipe recipe in _controller.GetRecipies(senderButton.ID)) { Button button = new RecipeButton(recipe.ID, recipe.Title, LoadRecipe, DeleteRecipe, LoadEditRecipe); RecipePanel.Children.Add(button); } RecipeButton newButton = new RecipeButton(0, "New recipe", ShowRecipeCreator, DeleteRecipe, LoadEditRecipe); RecipePanel.Children.Add(newButton); ShowRecipeCreator(null, null); }