示例#1
0
        public async Task RefreshData()
        {
            summary = await GameDataService.GetGameSummary();

            FirstDay  = summary.CurrentDay - 1;
            standings = await StandingsService.GetStandings(1, summary.CurrentYear, 1);

            playoffs = await PlayoffService.GetPlayoffSummary(2, summary.CurrentYear);

            if (Yesterday != null)
            {
                await Yesterday.RefreshData();
            }
            if (Today != null)
            {
                await Today.RefreshData();
            }
            if (Tomorrow != null)
            {
                await Tomorrow.RefreshData();
            }


            StateHasChanged();
        }
        private async Task GetPowerDetailsAsync()
        {
            try
            {
                PowerDetailsService pdService = PowerDetailsService.Instance();
                StandingsService    gsService = StandingsService.Instance();
                if (pdService.SelectedPower != null)
                {
                    PowerDetails = pdService.SelectedPower;
                    CancellationTokenSource cancelToken = new CancellationTokenSource();
                    PowerStanding = await gsService.GetPowerAsync(PowerDetails.ShortName, cancelToken).ConfigureAwait(false);

                    Cycle       = PowerStanding.Cycle;
                    LastUpdated = PowerStanding.LastUpdated;
                    ExpandText  = String.Format("<p>{0}</p>&nbsp;<ul><li>Strong Against: {1}</li><li>Weak Against: {2}</li></ul>",
                                                PowerDetails.ExpansionText,
                                                PowerDetails.ExpansionStrongGovernment,
                                                PowerDetails.ExpansionWeakGovernment);
                    ControlText = String.Format("<p>{0}</p>&nbsp;<ul><li>Strong Against: {1}</li><li>Weak Against: {2}</li></ul>",
                                                PowerDetails.ControlText,
                                                PowerDetails.ControlStrongGovernment,
                                                PowerDetails.ControlWeakGovernment);
                }
            }
            catch (Exception ex)
            {
                ToastHelper.Toast(String.Format("Error getting Power details: {0}", ex.Message));
            }
        }
 public TeamServiceTests()
 {
     mockTeamRepository   = new Mock <ITeamRepository>();
     mockGameRepository   = new Mock <IGameRepository>();
     mockStandingsService = new Mock <IStandingsService>();
     gameService          = new GameService(mockGameRepository.Object);
     teamService          = new TeamService(mockTeamRepository.Object, mockStandingsService.Object, mockGameRepository.Object);
     standingsService     = new StandingsService(mockGameRepository.Object);
 }
示例#4
0
 public NewSeasonProcessService(ILogger <FixturesController> logger,
                                GameService gameService,
                                TeamsService teamsService,
                                FixturesService fixturesService,
                                StandingsService standingsService)
 {
     _logger           = logger;
     _gameService      = gameService;
     _teamsService     = teamsService;
     _fixturesService  = fixturesService;
     _standingsService = standingsService;
 }
 public ChampionshipWeekProcessService(ILogger <FixturesController> logger,
                                       GameService gameService,
                                       FixturesService fixturesService,
                                       StandingsService standingsService,
                                       TeamsService teamsService)
 {
     _logger           = logger;
     _gameService      = gameService;
     _fixturesService  = fixturesService;
     _standingsService = standingsService;
     _teamsService     = teamsService;
 }
示例#6
0
        protected override void OnInitialized()
        {
            GameData = GameDataService.GetGameSummary().Result;
            var seasons = CompetitionService.GetCompetitionsByYear(GameData.CurrentYear).Result.Where(c => c.Type == CompetitionViewModel.SEASON_TYPE).ToList();

            if (seasons.Count > 0)
            {
                StandingsModel = StandingsService.GetStandings(seasons[0].Id, 1).Result;
            }
            else
            {
                StandingsModel = null;
            }

            DropDownState.OnChange += StateHasChanged;
        }
示例#7
0
        public TeamApplication()
        {
            leagueRepository            = new LeagueRepository(new RepositoryNHibernate <League>());
            teamRepository              = new TeamRepository(new RepositoryNHibernate <Team>());
            competitionRepository       = new CompetitionRepository(new RepositoryNHibernate <Competition>());
            standingsRepository         = new StandingsRepository(new RepositoryNHibernate <SeasonTeam>(), competitionRepository);
            teamRankingRepository       = new TeamRankingRepository(new RepositoryNHibernate <TeamRanking>());
            scheduleGameRepository      = new ScheduleGameRepository(new RepositoryNHibernate <ScheduleGame>());
            gameDataRepository          = new GameDataRepository(new RepositoryNHibernate <GameData>());
            competitionConfigRepository = new CompetitionConfigRepository(new RepositoryNHibernate <CompetitionConfig>());
            seasonRepository            = new SeasonRepository(new RepositoryNHibernate <Season>());
            competitionTeamRepository   = new CompetitionTeamRepository(new RepositoryNHibernate <CompetitionTeam>());

            LeagueService       = new LeagueService(leagueRepository);
            StandingsService    = new StandingsService(standingsRepository, competitionRepository);
            TeamService         = new TeamService(teamRepository);
            GameDataService     = new GameDataService(gameDataRepository, leagueRepository, scheduleGameRepository, competitionRepository, competitionConfigRepository, TeamService, CompetitionService);
            ScheduleGameService = new ScheduleGameService(scheduleGameRepository);
            CompetitionService  = new CompetitionService(competitionRepository);
            PlayoffService      = new PlayoffService(competitionRepository);
        }
示例#8
0
        private async void GetStandingsAsync(bool ignoreCache = false)
        {
            int cycleNo = 0;

            if (!string.IsNullOrWhiteSpace(Cycle))
            {
                int p = Cycle.IndexOf(" ") + 1;
                Int32.TryParse(Cycle.Substring(p, Cycle.Length - p), out cycleNo);
            }

            if ((Standings?.Any() == false) || (cycleNo != CycleService.CurrentCycle() && (LastUpdated + TimeSpan.FromMinutes(10) < DateTime.Now)))
            {
                ShowMessage = false;
                CancellationTokenSource cancelToken = new CancellationTokenSource();

                using (UserDialogs.Instance.Loading("Loading", () => cancelToken.Cancel(), null, true, MaskType.Clear))
                {
                    try
                    {
                        // get the standings
                        StandingsService  standingsService = StandingsService.Instance();
                        GalacticStandings standings        = await standingsService.GetData(cancelToken, ignoreCache).ConfigureAwait(false);

                        Cycle       = $"Cycle {standings.Cycle}";
                        LastUpdated = standings.LastUpdated;

                        if (standings.Standings.Count < 1)
                        {
                            SetMessages("Unable to display Powerplay Standings due to parsing error.", true);
                        }
                        else
                        {
                            // show the standings
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                Standings.Clear();
                                foreach (PowerStanding item in standings.Standings)
                                {
                                    Standings.Add(item);
                                }
                            });
                        }
                    }
                    catch (OperationCanceledException)
                    {
                        SetMessages("Powerplay Standings download was cancelled or timed out.", true);
                    }
                    catch (HttpRequestException ex)
                    {
                        string err   = ex.Message;
                        int    start = err.IndexOf("OPENSSL_internal:", StringComparison.OrdinalIgnoreCase);
                        if (start > 0)
                        {
                            start += 17;
                            int end = err.IndexOf(" ", start, StringComparison.OrdinalIgnoreCase);
                            err = $"SSL Error ({err.Substring(start, end - start).Trim()})";
                        }
                        else if (err.IndexOf("Error:", StringComparison.OrdinalIgnoreCase) > 0)
                        {
                            err = err.Substring(err.IndexOf("Error:", StringComparison.OrdinalIgnoreCase) + 6).Trim();
                        }
                        SetMessages($"Network Error: {err}", true);
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("unexpected end of stream"))
                        {
                            SetMessages("Powerplay Standings download was cancelled.", true);
                        }
                        else
                        {
                            SetMessages($"Error: {ex.Message}", true);
                        }
                    }
                }
            }
        }
示例#9
0
 public StandingsController(ILogger <StandingsController> logger, StandingsService standingsService)
 {
     _logger           = logger;
     _standingsService = standingsService;
 }
示例#10
0
        public void LeagueStandingsMethodReturnTheRightLeague()
        {
            var teamsList = new List <Team>()
            {
                new Team
                {
                    Id            = 1,
                    Name          = "Arsenal",
                    Wins          = 3,
                    Draws         = 1,
                    Looses        = 0,
                    ScoredGoals   = 11,
                    ConcededGoals = 2,
                    MatchesPlayed = 4,
                    Points        = 10,
                },
                new Team
                {
                    Id            = 2,
                    Name          = "Chelsea",
                    Wins          = 1,
                    Draws         = 1,
                    Looses        = 2,
                    ScoredGoals   = 5,
                    ConcededGoals = 11,
                    MatchesPlayed = 4,
                    Points        = 4,
                },
            };

            var leagueList = new List <League>()
            {
                new League
                {
                    Id    = 1,
                    Name  = "English Premier Division",
                    Teams = teamsList,
                },
                new League
                {
                    Id    = 2,
                    Name  = "Bundesliga",
                    Teams = teamsList,
                },
            };

            var leagueRepo = new Mock <IDeletableEntityRepository <League> >();

            leagueRepo.Setup(x => x.All()).Returns(leagueList.AsQueryable());

            var service = new StandingsService(leagueRepo.Object);

            var league = service.LeagueStandings("English Premier Division");

            var leagueName        = league.Name;
            var teamId            = league.Teams.Select(x => x.Id).FirstOrDefault();
            var teamName          = league.Teams.Select(x => x.Name).FirstOrDefault();
            var teamWins          = league.Teams.Select(x => x.Wins).FirstOrDefault();
            var teamDraws         = league.Teams.Select(x => x.Draws).FirstOrDefault();
            var teamLooses        = league.Teams.Select(x => x.Looses).FirstOrDefault();
            var teamScoredGoals   = league.Teams.Select(x => x.ScoredGoals).FirstOrDefault();
            var teamConcededGoals = league.Teams.Select(x => x.ConcededGoals).FirstOrDefault();
            var teamPlayedMatches = league.Teams.Select(x => x.MatchesPlayed).FirstOrDefault();
            var teamPoints        = league.Teams.Select(x => x.Points).FirstOrDefault();

            Assert.Equal("English Premier Division", leagueName);
            Assert.Equal(1, teamId);
            Assert.Equal("Arsenal", teamName);
            Assert.Equal(3, teamWins);
            Assert.Equal(1, teamDraws);
            Assert.Equal(0, teamLooses);
            Assert.Equal(11, teamScoredGoals);
            Assert.Equal(2, teamConcededGoals);
            Assert.Equal(4, teamPlayedMatches);
            Assert.Equal(10, teamPoints);

            leagueRepo.Verify(l => l.All(), Times.Once);
        }
示例#11
0
 public StandingsServiceTests()
 {
     repositoryMock = new Mock <IStandingsRepository>();
     service        = new StandingsService(repositoryMock.Object);
 }