public ActionResult DeleteConfirmed(int id)
{
Category category = db.Categories.Find(id);
// don't allow the category to be deleted if its being used
int postsWithCategory = db.Posts.Where(p => p.CategoryID == category.CategoryID).Count();
if (postsWithCategory > 0) {
return RedirectToAction("Delete");
}
// remove the category
db.Categories.Remove(category);
db.SaveChanges();
return RedirectToAction("Index");
}