public IActionResult Delete(int id)
 {
     using (var db = new Data.BookLibraryDbContext())
     {
         var bookToDelete = db.Books.Find(id);
         return(View(bookToDelete));
     }
 }
 public IActionResult Index()
 {
     using (var db = new Data.BookLibraryDbContext())
     {
         var books = db.Books.ToList();
         return(View(books));
     }
 }
        public IActionResult Delete(Book book)
        {
            using (var db = new Data.BookLibraryDbContext())
            {
                db.Books.Remove(book);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        public IActionResult Create(Book book)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            using (var db = new Data.BookLibraryDbContext())
            {
                db.Books.Add(book);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }