コード例 #1
0
        public async Task <ActionResult> UpdateGenre(int id, [FromBody] string genre)
        {
            var storedBook = await _context.GetBooksInInventory().SingleOrDefaultAsync(b => b.Id == id);

            if (storedBook != null)
            {
                storedBook.Genre = genre; // you need to validate it.
                await _context.SaveChangesAsync();

                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }