Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Author,Description,Status")] Book book)
        {
            if (id != book.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
        public async Task <ActionResult <Book> > Put(Book book)
        {
            if (book == null)
            {
                return(BadRequest());
            }
            if (!db.Books.Any(x => x.Id == book.Id))
            {
                return(NotFound());
            }

            db.Update(book);
            await db.SaveChangesAsync();

            return(Ok(book));
        }