public ActionResult Delete(int? id) { int ID = id ?? 0; if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Category category; using (Repos repo = new Repos()) { category = repo.GetCategoryByID(ID); } if (category == null) { return HttpNotFound(); } return View(category); }
public ActionResult DeleteConfirmed(int id) { Category category; using (Repos repo = new Repos()) { category = repo.GetCategoryByID(id); repo.DeleteCategory(category.CategoryID); } return RedirectToAction("Index"); }