public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            await _context.Books.AddAsync(Book);

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var BookFromDb = await _context.Books.FindAsync(Book.Id);

            BookFromDb.Name   = Book.Name;
            BookFromDb.Author = Book.Author;
            BookFromDb.ISBN   = Book.ISBN;

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            // If there's no id
            if (id == null)
            {
                return(NotFound());
            }

            // Searching for book by Id
            Book = await _context.Books.FindAsync(id);

            // If book doesn't exists
            if (Book != null)
            {
                _context.Books.Remove(Book);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }