public ActionResult Delete(int?id) { if (id != null) { IEnumerable <Book> list = books.GetAll().Where(b => b.Publisher.ID == (int)id); foreach (Book book in list) { book.Publisher = null; } publishers.Delete((int)id); } return(RedirectToAction("List")); }