コード例 #1
0
        public async Task <ActionResult <LeaderBoard> > PostLeaderBoard(LeaderBoard leaderBoard)
        {
            _context.LeaderBoard.Add(leaderBoard);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLeaderBoard", new { id = leaderBoard.PlayerId }, leaderBoard));
        }
コード例 #2
0
        public async Task <IActionResult> PutLeaderBoard(int id, LeaderBoard leaderBoard)
        {
            if (id != leaderBoard.PlayerId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }