Ejemplo n.º 1
0
        public async Task <IActionResult> PutBooks(int id, Books books)
        {
            if (id != books.BookId)
            {
                return(BadRequest());
            }

            _context.Entry(books).State = EntityState.Modified;
            //_context.Books.Update(books);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BooksExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("BookId,Title,Publisher")] Books books)
        {
            if (ModelState.IsValid)
            {
                _context.Add(books);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(books));
        }