Ejemplo n.º 1
0
        private void GetUpcomingFixtures()
        {
            string request = string.Format("seasons/296/upcoming?access_token={0}", authToken.new_access_token);
            HttpResponseMessage response = client.GetAsync(request).Result;

            response.EnsureSuccessStatusCode();
            FixtureResponse fixtureResponse = JsonConvert.DeserializeObject <FixtureResponse>(response.Content.ReadAsStringAsync().Result);

            upcoming = fixtureResponse.docs.ToList();
        }
Ejemplo n.º 2
0
        private void CalculatePoints()
        {
            bool           done        = false;
            int            page        = 1;
            List <Fixture> finished    = new List <Fixture>();
            List <string>  validRounds = new List <string>()
            {
                "1", "2", "3"
            };

            do
            {
                string request = string.Format("seasons/296/fixtures?page={0}&access_token={1}", page, authToken.new_access_token);
                HttpResponseMessage response = client.GetAsync(request).Result;
                response.EnsureSuccessStatusCode();
                FixtureResponse fixtureResponse = JsonConvert.DeserializeObject <FixtureResponse>(response.Content.ReadAsStringAsync().Result);
                finished.AddRange(fixtureResponse.docs.ToList().Where(f => (f.fixture_status_short == "FIN" && validRounds.Contains(f.round))).ToList());
                done = (page == fixtureResponse.pagination.pages);
                page++;
            } while (!done);

            foreach (Quinielero q in quinieleros)
            {
                q.Reset();
            }
            foreach (Fixture f in finished)
            {
                quinieleros.Where(q => q.teams.Contains(f.team_season_away_name)).First().playedGames++;
                quinieleros.Where(q => q.teams.Contains(f.team_season_home_name)).First().playedGames++;

                if (f.number_goal_team_away == f.number_goal_team_home)
                {
                    quinieleros.Where(q => q.teams.Contains(f.team_season_away_name)).First().points += 1;
                    quinieleros.Where(q => q.teams.Contains(f.team_season_home_name)).First().points += 1;
                    quinieleros.Where(q => q.teams.Contains(f.team_season_away_name)).First().teamRecords[f.team_season_away_name].Tie++;
                    quinieleros.Where(q => q.teams.Contains(f.team_season_home_name)).First().teamRecords[f.team_season_home_name].Tie++;
                }
                else if (f.number_goal_team_away > f.number_goal_team_home)
                {
                    quinieleros.Where(q => q.teams.Contains(f.team_season_away_name)).First().points += 3;
                    quinieleros.Where(q => q.teams.Contains(f.team_season_away_name)).First().teamRecords[f.team_season_away_name].Win++;
                    quinieleros.Where(q => q.teams.Contains(f.team_season_home_name)).First().teamRecords[f.team_season_home_name].Lose++;
                }
                else
                {
                    quinieleros.Where(q => q.teams.Contains(f.team_season_home_name)).First().points += 3;
                    quinieleros.Where(q => q.teams.Contains(f.team_season_home_name)).First().teamRecords[f.team_season_home_name].Win++;
                    quinieleros.Where(q => q.teams.Contains(f.team_season_away_name)).First().teamRecords[f.team_season_away_name].Lose++;
                }
            }
        }