Пример #1
0
        private void AnalyzeLeagueSeason(LeagueSeason season)
        {
            var allSeasonGames = leagueRepo.GetAllSeasonGames(season.LeagueSeasonId);
            var analyzedGames  = systemRepo.GetBookmakerOddsStatsAnalyzeGames(season.LeagueSeasonId);

            var processedGames = new List <int>();

            foreach (var game in allSeasonGames)
            {
                if (game.Result == 0 || analyzedGames.FindIndex(g => g.GameId == game.GameId) >= 0)
                {
                    continue;
                }
                var gameOddsStats = new BookmakerOddsStats
                {
                    GameId = game.GameId
                };

                ComputeBookmakerOddsStats(gameOddsStats, game);

                analysisRepo.AddOrUpdateBookmakerOddsStats(gameOddsStats);
                processedGames.Add(game.GameId);
            }

            systemRepo.AddAnalyzedGames_BookmakerOddsStats(processedGames, season.LeagueSeasonId);
        }
Пример #2
0
        private void UpdateLeagueSeason(LeagueSeason season)
        {
            var seasonTeams    = analysisRepo.GetSeasonTeamsCount(season.LeagueSeasonId);
            var seasonRound    = leagueRepo.GetSeasonRoundCount(season.LeagueSeasonId);
            var allSeasonGames = leagueRepo.GetAllSeasonGames(season.LeagueSeasonId).OrderBy(g => g.Date);

            season.CountOfRounds = seasonRound;
            season.CountOfTeams  = seasonTeams;
            if (allSeasonGames.Any())
            {
                season.StartDate = allSeasonGames.First().Date;
                if (allSeasonGames.Count() >= 380)
                {
                    season.EndDate = allSeasonGames.Last().Date;
                }
            }

            leagueRepo.UpdateLeagueSeason(season);
        }
        private bool CheckRoundGames(int seasonId, List <SeasonRound> rounds)
        {
            var result         = true;
            var allGames       = leagueRepo.GetAllSeasonGames(seasonId).OrderBy(g => g.Date).ToList();
            var nextRoundIndex = 1;
            var currentRound   = rounds.First();
            var i = 0;

            foreach (var game in allGames)
            {
                if (i == 10)
                {
                    i            = 0;
                    currentRound = rounds[nextRoundIndex++];
                }
                game.RoundId = currentRound.RoundId;
                leagueRepo.UpdateGameRecord(game);
                i++;
            }

            return(result);;
        }
Пример #4
0
        private void AnalyzedTeam(LeagueSeasonTeams team)
        {
            var teamsSeasonGames = leagueRepo.GetAllSeasonGames(team.LeagueSeasonId)
                                   .Where(g => g.HomeTeamId == team.FootballTeamId || g.AwayTeamId == team.FootballTeamId);
            var teamForm5 = new FootballTeamForm
            {
                TeamId         = team.FootballTeamId,
                LeagueSeasonId = team.LeagueSeasonId,
                TimePeriod     = TimePeriod.Last5Matches
            };
            var teamForm10 = new FootballTeamForm
            {
                TeamId         = team.FootballTeamId,
                LeagueSeasonId = team.LeagueSeasonId,
                TimePeriod     = TimePeriod.Last10Matches
            };
            var teamFormAll = new FootballTeamForm
            {
                TeamId         = team.FootballTeamId,
                LeagueSeasonId = team.LeagueSeasonId,
                TimePeriod     = TimePeriod.AllMatches
            };

            var teamFormAllHome = new FootballTeamForm
            {
                TeamId         = team.FootballTeamId,
                LeagueSeasonId = team.LeagueSeasonId,
                TimePeriod     = TimePeriod.AllHomeMatches
            };

            var teamFormAllAway = new FootballTeamForm
            {
                TeamId         = team.FootballTeamId,
                LeagueSeasonId = team.LeagueSeasonId,
                TimePeriod     = TimePeriod.AllAwayMatches
            };

            var i = 0;

            foreach (var game in teamsSeasonGames)
            {
                if (game.Result == 0)
                {
                    continue;
                }
                var gameTotal = game.HomeTeamGoals + game.AwayTeamGoals;
                ComputeTeamFormByGame(teamFormAll, game);
                if (i < 5)
                {
                    ComputeTeamFormByGame(teamForm5, game);
                }
                if (i < 10)
                {
                    ComputeTeamFormByGame(teamForm10, game);
                }

                if (game.HomeTeamId == team.FootballTeamId)
                {
                    ComputeTeamFormByGame(teamFormAllHome, game);
                }
                else
                {
                    ComputeTeamFormByGame(teamFormAllAway, game);
                }

                i++;
            }

            analysisRepo.AddOrUpdateTeamForm(teamForm5);
            analysisRepo.AddOrUpdateTeamForm(teamForm10);
            analysisRepo.AddOrUpdateTeamForm(teamFormAll);
            analysisRepo.AddOrUpdateTeamForm(teamFormAllHome);
            analysisRepo.AddOrUpdateTeamForm(teamFormAllAway);
        }