Exemplo n.º 1
0
        public async Task <IActionResult> PutToken(int id, Token token)
        {
            if (id != token.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task<IActionResult> PutClub(int id, Club club)
        {
            if (id != club.Id)
            {
                return BadRequest();
            }

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

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

            return NoContent();
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutPlayer(int id, Player player)
        {
            if (id != player.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();

                return(Ok(player));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PlayerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutGame(int id, Game game)
        {
            if (id != game.Id)
            {
                return(BadRequest());
            }

            var player1 = await _context.Player.FindAsync(game.Player1Id);

            var player2 = await _context.Player.FindAsync(game.Player2Id);

            if (player1 == null)
            {
                return(BadRequest("Player1 with id = " + game.Player1Id + " does not exist"));
            }
            if (player2 == null)
            {
                return(BadRequest("Player2 with id = " + game.Player2Id + " does not exist"));
            }

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

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

            return(Ok(game));
        }