/// <summary>
        /// if the date selected is todays date then load the live matches and add to the matches already played
        /// </summary>
        private async void CheckDate()
        {
            try
            {
                var todaysDate = DateTime.Parse(DateTime.Now.ToString().Split(' ')[0]);

                MatchList = (DateSelected == todaysDate) ?
                            await repository.LoadLive() :
                            new List <Match>();

                MatchList = (PastMatchList?.Count != 0) ?
                            MatchList.Concat(PastMatchList).ToList() :
                            MatchList;
                CreateGroupedList();
            }
            catch (Exception ex)
            {
                errorHandler.CheckErrorMessage(ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// When receiving the team
        /// </summary>
        /// <param name="teamId"></param>
        private async void TeamSelected(string teamId)
        {
            if (teamId.Contains("teamId"))
            {
                var TeamId = teamId.Split('=')[1];
                //get team id and load all it's matches and fixtures
                GetMatchesAndFixtures(TeamId);

                //loop through the live matches to find if the team is currently playing
                foreach (Match match in await repository.LoadLive())
                {
                    if (TeamId == match.home_id || TeamId == match.away_id)
                    {
                        CurrentlyLive  = true;
                        LiveMatch      = match;
                        LiveMatch.date = "LIVE";
                        return;
                    }
                    else
                    {
                        CurrentlyLive = false;
                    }
                }
            }

            if (teamId.Contains("teamName"))
            {
                TeamName = teamId.Split('=')[1];

                //load the team logo
                foreach (Logo logo in repository.LoadLogos())
                {
                    if (TeamName.ToLower() == logo.team_name.ToLower())
                    {
                        TeamLogo = logo.logo;
                        return;
                    }
                    if (TeamName.Contains(logo.team_name) ||
                        $"FC {TeamName}".Contains(logo.team_name) ||
                        $"{TeamName} FC".Contains(logo.team_name))
                    {
                        TeamLogo = logo.logo;
                        return;
                    }
                    TeamLogo = "";
                }
            }
        }