private void Delete_Click(object sender, EventArgs e) { // get what we want to delete. var category = GetSelectedCategory(); if (null == category) { // how did we get here? return; } // confirmation. if (DialogResult.No == MessageBox.Show($"Are you sure you want to delete '{category.Name}'", "Delete Category", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ) { return; } // try and delete the category. if (!_categories.DeleteCategory(category.Name)) { MessageBox.Show("There was an error deleting the category.", "Delete Category", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // reload all the categories. _categories.ReloadCategories(); // reload the values. ReloadCategories(); }
public ActionResult Delete(Category category) { if (category == null) { throw new ArgumentNullException(); } _categoriesStorage.DeleteCategory(category.ID); return(RedirectToAction("ShowAll")); }