Ejemplo n.º 1
0
        public override void Run()
        {
            var config = GetConfig();

            var context = new BasketballDataContext(config);

            // UPDATE ODDS FOR GAMES STARTING IN NEXT 24 HOURS
            var targetedApiBasketballLeagueSeasonInfos = context.Games.Where(x => x.LeagueSeason.IsActive)
                                                         .Select(x => new { x.LeagueSeason.ApiBasketballLeagueId, x.LeagueSeason.ApiBasketballSeasonKey })
                                                         .Distinct()
                                                         .ToList();

            if (targetedApiBasketballLeagueSeasonInfos != null && targetedApiBasketballLeagueSeasonInfos.Count > 0)
            {
                var bookmakersDict = context.Bookmakers.ToDictionary(x => x.ApiBasketballBookmakerId, y => y.BookmakerId);
                var betTypesDict   = context.BetTypes.ToDictionary(x => x.ApiBasketballBetTypeId, y => y.BetTypeId);

                for (int i = 0; i < targetedApiBasketballLeagueSeasonInfos.Count; i++)
                {
                    var leagueSeasonInfo = targetedApiBasketballLeagueSeasonInfos[i];
                    var oddsProcessor    = new OddsProcessor(leagueSeasonInfo.ApiBasketballLeagueId, leagueSeasonInfo.ApiBasketballSeasonKey, betTypesDict, bookmakersDict);
                    oddsProcessor.Run(context);
                    context.SaveChanges();

                    if (i % 10 == 9)
                    {
                        context.Dispose();
                        context = new BasketballDataContext(config);
                    }
                }
            }

            context.Dispose();
        }
Ejemplo n.º 2
0
        public override void Run()
        {
            var config = GetConfig();

            var context = new BasketballDataContext(config);

            var activeLeagueSeasons = context.LeagueSeasons.Where(x => x.IsActive).ToList();

            if (activeLeagueSeasons != null && activeLeagueSeasons.Count > 0)
            {
                var countriesDict = context.Countries.ToDictionary(x => x.ApiBasketballCountryId, y => y.CountryId);
                var statusDict    = context.RefGameStatuses
                                    .Where(x => !string.IsNullOrEmpty(x.ApiBasketballStatusCode))
                                    .ToDictionary(x => x.ApiBasketballStatusCode, y => y.FullGameStatusId);
                for (int i = 0; i < activeLeagueSeasons.Count; i++)
                {
                    var leagueSeason = activeLeagueSeasons[i];

                    var gamesProcessor = new GamesProcessor(leagueSeason.ApiBasketballLeagueId, leagueSeason.ApiBasketballSeasonKey, countriesDict, statusDict);
                    gamesProcessor.Run(context);
                    context.SaveChanges();

                    if (i % 10 == 9)
                    {
                        context.Dispose();
                        context = new BasketballDataContext(config);
                    }
                }
            }
            context.Dispose();
        }