Ejemplo n.º 1
0
        public async Task <ActionResult <GameOfGenre> > PostGameOfGenre(GameOfGenre gameOfGenre)
        {
            _context.GamesOfGenres.Add(gameOfGenre);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetGameOfGenre", new { id = gameOfGenre.Id }, gameOfGenre));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutGameOfGenre(int id, GameOfGenre gameOfGenre)
        {
            if (id != gameOfGenre.Id)
            {
                return(BadRequest());
            }

            _context.Entry(gameOfGenre).State = EntityState.Modified;

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

            return(NoContent());
        }