public ActionResult DeleteBook(int id) { LibraryManagementSystemContext context = new LibraryManagementSystemContext(); BooksRepository booksRepository = new BooksRepository(context); BooksDeleteBookVM model = new BooksDeleteBookVM(); Book book = booksRepository.GetByID(id); model.ID = book.ID; model.Title = book.Title; return(View(model)); }
public ActionResult DeleteBook(BooksDeleteBookVM model) { LibraryManagementSystemContext context = new LibraryManagementSystemContext(); BooksRepository booksRepository = new BooksRepository(context); Book book = booksRepository.GetByID(model.ID); if (book == null) { return(HttpNotFound()); } else { booksRepository.Delete(book); } return(RedirectToAction("Index")); }