コード例 #1
0
        /// <summary>
        /// gets all the fixtures for the date selected
        /// </summary>
        private async void GetFixtures()
        {
            try
            {
                var todaysDate = DateTime.Parse(DateTime.Now.ToString().Split(' ')[0]);
                int i          = 0;
                //Load the fixtures from multiple pages if the date selected is today or a future date
                if (DateSelected >= todaysDate)
                {
                    var FixturePageList = new List <Fixture>();
                    do
                    {
                        i           = i + 1;
                        FixtureList = await repository.LoadFixture(DateSelected, "", i);

                        FixturePageList = FixturePageList.Concat(FixtureList).ToList();
                    } while (FixtureList.Count == 30);
                    FixtureList = FixturePageList;
                }
                else
                {
                    FixtureList = new List <Fixture>();
                }

                //Load the past matches from multiple pages if the date selected is today or a day in the past
                if (DateSelected <= todaysDate)
                {
                    i = 0;
                    var prevMatches = new List <Match>();
                    do
                    {
                        i             = i + 1;
                        PastMatchList = await repository.LoadPast(DateSelected, "", i);

                        prevMatches = prevMatches.Concat(PastMatchList).ToList();
                    } while (PastMatchList.Count == 30);
                    PastMatchList = prevMatches;
                }
                else
                {
                    PastMatchList = new List <Match>();
                }

                //if countries haven't been loaded before
                if (!CountriesLoaded)
                {
                    LoadCountries();
                }
                else
                {
                    //date changed
                    if (!InvokedByFixtureTimer)
                    {
                        CheckDate();
                    }
                    //fixture timer
                    else
                    {
                        CreateGroupedList();
                    }
                }
                InvokedByFixtureTimer = false;
            }
            catch (Exception ex)
            {
                errorHandler.CheckErrorMessage(ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// loads all the teams upcoming fixtures and past matches by the teamId
        /// </summary>
        /// <param name="teamId"></param>
        private async void GetMatchesAndFixtures(string teamId)
        {
            try
            {
                Messenger.Default.Send("unloaded");
                if (CurrentTeam == teamId)
                {
                    return;                        //if same team is already selected
                }
                CurrentTeam = teamId;
                int i = 0;

                var FixturePageList = new List <Fixture>();
                var futureFixtures  = new List <Fixture>();
                do //load all fixtures from multiple pages
                {
                    i = i + 1;
                    futureFixtures = await repository.LoadFixture(null, teamId, i);

                    FixturePageList = FixturePageList.Concat(futureFixtures).ToList();
                } while (futureFixtures.Count == 30);

                FixturePageList.Reverse(); //reorder the list
                //loop through fixtures and format the date and time
                foreach (Fixture fixture in FixturePageList)
                {
                    if (fixture.time.Length > 3)
                    {
                        fixture.time = fixture.time.Substring(0, fixture.time.Length - 3);
                    }

                    string[] date = fixture.date.Split('-');
                    fixture.date  = $"{date[2]}/{date[1]}/{date[0]}";
                    fixture.round = "";
                }
                UpcomingFixtureList = FixturePageList;

                i = 0;
                var MatchPageList = new List <Match>();
                var prevMatches   = new List <Match>();
                do //load all matches from multiple pages
                {
                    i           = i + 1;
                    prevMatches = await repository.LoadPastForTeam(teamId, i);

                    MatchPageList = MatchPageList.Concat(prevMatches).ToList();
                } while (prevMatches.Count == 30);

                MatchPageList.Reverse(); //reorder the list
                //loop through the match to format the date
                foreach (Match match in MatchPageList)
                {
                    string[] date = match.date.Split('-');
                    match.date = $"{date[2]}/{date[1]}/{date[0]}";
                }
                //if team is playing then add that match to the beginning of the list
                if (CurrentlyLive)
                {
                    MatchPageList.Insert(0, LiveMatch);
                }
                PastMatchList = MatchPageList;
            }
            catch (Exception ex)
            {
                errorHandler.CheckErrorMessage(ex);
            }
            finally
            {
                Messenger.Default.Send("loaded");
            }
        }