Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Title,Author,Description,Status")] Book book)
        {
            if (ModelState.IsValid)
            {
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <Book> > Post(Book book)
        {
            if (book == null)
            {
                return(BadRequest());
            }

            db.Books.Add(book);
            await db.SaveChangesAsync();

            return(Ok(book));
        }