예제 #1
0
        public async Task <IHttpActionResult> GetTournament(int id)
        {
            Tournament tournament = await db.Tournaments.FindAsync(id);

            db.Entry(tournament).Collection(r => r.Rankings).Load();
            db.Entry(tournament).Collection(r => r.Phases).Load();
            db.Entry(tournament).Collection(r => r.Participants).Load();

            if (tournament == null)
            {
                return(NotFound());
            }

            return(Ok(tournament));
        }
예제 #2
0
        public async Task <IHttpActionResult> PutGame(int id, Game game)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != game.GameId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }