Esempio n. 1
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 = "";
                }
            }
        }
Esempio n. 2
0
        public TeamStatisticsViewModel(ITeamClient teamClient, IStatisticsClient statisticsClient, ITimerService timerService, IEventAggregator eventAggregator, ICacheService cacheService)
        {
            _teamClient = teamClient;
            _statisticsClient = statisticsClient;
            timerService.Start(TimeSpan.FromSeconds(10), OnRefresh);
            _eventAggregator = eventAggregator;
            _cacheService = cacheService;

            Func<Boolean> canExecute = () =>
            {
                var password = new NetworkCredential(string.Empty, TeamPassword).Password;
                return !String.IsNullOrWhiteSpace(TeamName) && !TeamName.Contains(" ") &&
                       !String.IsNullOrWhiteSpace(password) && !password.Contains(" ");
            };

            AcceptExistingTeamCommand = new RelayCommand(OnAcceptExistingTeam, canExecute);
            CreateNewTeamCommand = new RelayCommand(OnCreateNewTeam, canExecute);
        }