예제 #1
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();
        }
예제 #2
0
        // query games function
        public async Task <DashboardGameBundle> FetchGames(string gameName = null)
        {
            ViewBag.MaxRating = (int)HttpContext.Session.GetInt32("MaxRating");
            ViewBag.MinRating = (int)HttpContext.Session.GetInt32("MinRating");
            var games = new List <Game>();

            if (gameName != null)
            {
                games = await GamesProcessor.LoadGamesBasedOnSearch(gameName);
            }
            else
            {
                games = await GamesProcessor.LoadGamesBasedOnFilters(MinRating : ViewBag.MinRating, MaxRating : ViewBag.MaxRating, genre : HttpContext.Session.GetString("Genre"), platform : HttpContext.Session.GetString("Platform"));
            }

            var DashboardBundle = new DashboardGameBundle();

            if (games.Count > 0)
            {
                DashboardBundle.popularGames = await GamesProcessor.LoadPopularGames();
            }
            DashboardBundle.games = games;

            return(DashboardBundle);
        }
예제 #3
0
        public GameWindow()
        {
            InitializeComponent();
            ApiHelper.InitializeClient();

            gamesProcessor   = new GamesProcessor();
            resultsProcessor = new ResultsProcessor();
            membersProcessor = new MembersProcessor();
            leaguesProcessor = new LeaguesProcessor();

            membersWithGames   = new List <MemberDTO>();
            membersWithResults = new List <MemberDTO>();
        }
예제 #4
0
        public static async Task MainAsync(Configuration configuration, CancellationToken cancel)
        {
            var persistence      = new JsonFileKeyValueStore(new FileInfo(configuration.Get("db-file-location")));
            var gamesPersistence = new JsonFileKeyValueStore(new FileInfo(configuration.Get("games-db-location")));

            var slackApi = new SlackApi(configuration.Get("slack-api-key"));

            var slackRtm = await(ReconnectingSlackRealTimeMessaging.CreateAsync(
                                     async() => await slackApi.StartRtm()));
            var aliasList = GetAliasList(slackRtm.InstanceInfo.Users);

            var commandParser = new SlackCommandParser("scbot", slackRtm.InstanceInfo.BotId);

            var webClient = new WebClient();

            var features = new FeatureMessageProcessor(commandParser,
                                                       NoteProcessor.Create(commandParser, persistence),
                                                       //ZendeskTicketTracker.Create(commandParser, persistence, configuration),
                                                       RecordReplayTraceManagement.Create(commandParser),
                                                       SeatingPlans.Create(commandParser, webClient),
                                                       Webcams.Create(commandParser, configuration),
                                                       Silly.Create(commandParser, webClient),
                                                       Installers.Create(commandParser, webClient),
                                                       Polls.Create(commandParser),
                                                       RollBuildNumbers.Create(commandParser, configuration),
                                                       ReviewFactory.Create(commandParser, webClient, configuration),
                                                       LabelPrinting.Create(commandParser, webClient, configuration),
                                                       Jira.Create(commandParser),
                                                       CompareTeamEmails.Create(commandParser, configuration),
                                                       GamesProcessor.Create(commandParser, gamesPersistence, aliasList)
                                                       );

            var pasteBin = new HasteServerPasteBin(webClient, configuration.Get("haste-server-url"));

            var newChannelNotificationsChannel = configuration.GetWithDefault("new-channels-notification-channel", null);
            var newChannelProcessor            = GetNewChannelProcessor(newChannelNotificationsChannel);

            var bot = new Bot(
                new ErrorReportingMessageProcessor(
                    new ConcattingMessageProcessor(features),
                    pasteBin),
                newChannelProcessor);

            var handler = new SlackMessageHandler(bot, slackRtm.InstanceInfo.BotId);

            MainLoop(slackRtm, handler, slackApi, cancel);
        }
예제 #5
0
        public async Task <IActionResult> ShowGame(int gameId)
        {
            var user_id = HttpContext.Session.GetInt32("user_id");

            if (user_id == null)
            {
                return(RedirectToAction("LoginAndRegister", "LoginAndRegister"));
            }

            var gameProfileBundle = new GameProfileBundle();

            gameProfileBundle.user = dbContext.Users.FirstOrDefault(user => user.user_id == user_id);


            if (dbContext.Games.FirstOrDefault(game => game.gameId == gameId) == null)
            {
                Game game = await GamesProcessor.ShowOneGame(gameId);

                SaveGame(game);
            }

            gameProfileBundle.game = dbContext.Games.Include(g => g.cover)
                                     .Include(g => g.game_Genres).ThenInclude(g => g.genre)
                                     .Include(g => g.game_Companies).ThenInclude(invc => invc.company)
                                     .Include(g => g.game_Platforms).ThenInclude(p => p.platform)
                                     .Include(g => g.screenshots)
                                     .Include(g => g.videos)
                                     .Include(g => g.expansions).ThenInclude(e => e.cover)
                                     .Include(g => g.Reviews).ThenInclude(r => r.reviewer)
                                     .Include(g => g.Reviews).ThenInclude(r => r.likeCounts)
                                     .Include(g => g.Reviews).ThenInclude(r => r.responses)
                                     .FirstOrDefault(g => g.gameId == gameId);


            gameProfileBundle.formReview = new Review();
            gameProfileBundle.Comment    = new ReviewResponse();
            ViewBag.userName             = HttpContext.Session.GetString("userName");
            return(View("GameProfile", gameProfileBundle));
        }
예제 #6
0
        public override void Run()
        {
            var config = GetConfig();

            using (var context = new BasketballDataContext(config))
            {
                // ASSUME ALL GAMES ARE IN DB FROM DAILY TASK

                // UPDATE RESULTS FOR LIVE/RECENTLY FINAL GAMES
                // SELECT LEAGUE SEASONS WHERE
                // 1) A GAME HAS STARTED SINCE THE LAST UNIVERSAL GAME HAS GONE FINAL (PICKUP GAMES AFTER PERIOD WITHOUT RUNNING)
                // 2) A GAME IS LIVE
                // 3) THE GAME WILL START IN THE NEXT 4 HOURS
                DateTime lastFinalGameStart = context.Games.Where(x => liveOrFinalGameStatuses.Contains(x.FullGameStatusId)).Max(x => x.GameTimeUtc);
                var      targetedApiBasketballLeagueSeasonInfos = context.Games.Where(x => x.LeagueSeason.IsActive &&
                                                                                      x.GameTimeUtc > lastFinalGameStart &&
                                                                                      liveOrPregameGameStatuses.Contains(x.FullGameStatusId) &&
                                                                                      x.GameTimeUtc <= DateTime.UtcNow.AddHours(4))
                                                                  .Select(x => new { x.LeagueSeason.ApiBasketballLeagueId, x.LeagueSeason.ApiBasketballSeasonKey })
                                                                  .Distinct()
                                                                  .ToList();

                if (targetedApiBasketballLeagueSeasonInfos != null && targetedApiBasketballLeagueSeasonInfos.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);

                    foreach (var leagueSeasonInfo in targetedApiBasketballLeagueSeasonInfos)
                    {
                        var gamesProcessor = new GamesProcessor(leagueSeasonInfo.ApiBasketballLeagueId, leagueSeasonInfo.ApiBasketballSeasonKey, countriesDict, statusDict);
                        gamesProcessor.Run(context);
                        context.SaveChanges();
                    }
                }
            }
        }
예제 #7
0
        public override void Run()
        {
            Console.WriteLine("Hello World!");
            HockeyDataContext context = null;

            try
            {
                var config = GetConfig();

                context = new HockeyDataContext(config);

                //context.Database.EnsureDeleted();
                //context.Database.EnsureCreated();
                //context.SaveChanges();

                //context.RefGameTypes.AddRange(new List<RefGameType>
                //{
                //	new RefGameType{ GameTypeId = GameType.Unknown, NhlGameTypeKey = string.Empty, GameTypeDescription = "Unknown"},
                //	new RefGameType{ GameTypeId = GameType.RegularSeason, NhlGameTypeKey = "R", GameTypeDescription = "Regular Season"},
                //	new RefGameType{ GameTypeId = GameType.Postseason, NhlGameTypeKey = "P", GameTypeDescription = "Postseason"},
                //	new RefGameType{ GameTypeId = GameType.Preseason, NhlGameTypeKey = "PR", GameTypeDescription = "Preseason"},
                //	new RefGameType{ GameTypeId = GameType.AllStarGame, NhlGameTypeKey = "A", GameTypeDescription = "All-Star Game"},
                //	new RefGameType{ GameTypeId = GameType.AllStarGameWomen, NhlGameTypeKey = "WA", GameTypeDescription = "All-Star Women Game"},
                //	new RefGameType{ GameTypeId = GameType.Olympics, NhlGameTypeKey = "O", GameTypeDescription = "Olympics Game"},
                //	new RefGameType{ GameTypeId = GameType.Exhibition, NhlGameTypeKey = "E", GameTypeDescription = "Exhibition"},
                //	new RefGameType{ GameTypeId = GameType.WorldCupExhibition, NhlGameTypeKey = "WCOH_EXH", GameTypeDescription = "World Cup of Hockey exhibition/preseason games "},
                //	new RefGameType{ GameTypeId = GameType.WorldCupPrelim, NhlGameTypeKey = "WCOH_PRELIM", GameTypeDescription = "World Cup of Hockey preliminary games"},
                //	new RefGameType{ GameTypeId = GameType.WorldCupFinal, NhlGameTypeKey = "WCOH_FINAL", GameTypeDescription = "World Cup of Hockey semifinals and finals"},
                //});
                //context.SaveChanges();

                //context.RefGameStatuses.AddRange(new List<RefGameStatus>
                //{
                //	new RefGameStatus{ DetailedGameStatusId = DetailedGameStatus.Scheduled, GameStatusId = GameStatus.Pregame, NhlStatusCode = 01, GameStatusName = "Pregame", DetailedGameStatusName = "Scheduled"},
                //	new RefGameStatus{ DetailedGameStatusId = DetailedGameStatus.Pregame, GameStatusId = GameStatus.Pregame, NhlStatusCode = 02, GameStatusName = "Pregame", DetailedGameStatusName = "Pregame"},
                //	new RefGameStatus{ DetailedGameStatusId = DetailedGameStatus.InProgress, GameStatusId = GameStatus.Live, NhlStatusCode = 03, GameStatusName = "Live", DetailedGameStatusName = "In-Progress"},
                //	new RefGameStatus{ DetailedGameStatusId = DetailedGameStatus.InProgressCritical, GameStatusId = GameStatus.Live, NhlStatusCode = 04, GameStatusName = "Live", DetailedGameStatusName = "In-Progress - Critical"},
                //	new RefGameStatus{ DetailedGameStatusId = DetailedGameStatus.GameOver, GameStatusId = GameStatus.Final, NhlStatusCode = 05, GameStatusName = "Final", DetailedGameStatusName = "Game Over"},
                //	new RefGameStatus{ DetailedGameStatusId = DetailedGameStatus.Final, GameStatusId = GameStatus.Final, NhlStatusCode = 06, GameStatusName = "Final", DetailedGameStatusName = "Final"},
                //	new RefGameStatus{ DetailedGameStatusId = DetailedGameStatus.Final2, GameStatusId = GameStatus.Final, NhlStatusCode = 07, GameStatusName = "Final", DetailedGameStatusName = "Final"},
                //	new RefGameStatus{ DetailedGameStatusId = DetailedGameStatus.ScheduledTbd, GameStatusId = GameStatus.Pregame, NhlStatusCode = 08, GameStatusName = "Pregame", DetailedGameStatusName = "Scheduled (Time TBD)"},
                //	new RefGameStatus{ DetailedGameStatusId = DetailedGameStatus.Postponed, GameStatusId = GameStatus.Postponed, NhlStatusCode = 09, GameStatusName = "Postponed", DetailedGameStatusName = "Postponed"},
                //});
                //context.SaveChanges();

                //context.RefPlayTypes.AddRange(new List<RefPlayType>
                //{
                //	new RefPlayType{ PlayTypeId = PlayType.BlockedShot, NhlCode = "BLOCKED_SHOT", PlayTypeName = "Blocked Shot" },
                //	new RefPlayType{ PlayTypeId = PlayType.Faceoff, NhlCode = "FACEOFF", PlayTypeName = "Faceoff" },
                //	new RefPlayType{ PlayTypeId = PlayType.GameEnd, NhlCode = "GAME_END", PlayTypeName = "Game End" },
                //	new RefPlayType{ PlayTypeId = PlayType.GameScheduled, NhlCode = "GAME_SCHEDULED", PlayTypeName = "Game Scheduled" },
                //	new RefPlayType{ PlayTypeId = PlayType.Giveaway, NhlCode = "GIVEAWAY", PlayTypeName = "Giveaway" },
                //	new RefPlayType{ PlayTypeId = PlayType.Goal, NhlCode = "GOAL", PlayTypeName = "Goal" },
                //	new RefPlayType{ PlayTypeId = PlayType.Hit, NhlCode = "HIT", PlayTypeName = "Hit" },
                //	new RefPlayType{ PlayTypeId = PlayType.MissedShot, NhlCode = "MISSED_SHOT", PlayTypeName = "Missed Shot" },
                //	new RefPlayType{ PlayTypeId = PlayType.Penalty, NhlCode = "PENALTY", PlayTypeName = "Penalty" },
                //	new RefPlayType{ PlayTypeId = PlayType.PeriodEnd, NhlCode = "PERIOD_END", PlayTypeName = "Period End" },
                //	new RefPlayType{ PlayTypeId = PlayType.PeriodOfficial, NhlCode = "PERIOD_OFFICIAL", PlayTypeName = "Period Official" },
                //	new RefPlayType{ PlayTypeId = PlayType.PeriodReady, NhlCode = "PERIOD_READY", PlayTypeName = "Period Ready" },
                //	new RefPlayType{ PlayTypeId = PlayType.PeriodStart, NhlCode = "PERIOD_START", PlayTypeName = "Period Start" },
                //	new RefPlayType{ PlayTypeId = PlayType.Shot, NhlCode = "SHOT", PlayTypeName = "Shot" },
                //	new RefPlayType{ PlayTypeId = PlayType.Stoppage, NhlCode = "STOP", PlayTypeName = "Stoppage" },
                //	new RefPlayType{ PlayTypeId = PlayType.Takeaway, NhlCode = "TAKEAWAY", PlayTypeName = "Takeaway" },
                //});
                //context.SaveChanges();

                //context.RefStoppageTypes.AddRange(new List<RefStoppageType>
                //{
                //	new RefStoppageType{ StoppageTypeId = StoppageType.Unknown, NhlDescription = null , StoppageName = "Unknown"},
                //	new RefStoppageType{ StoppageTypeId = StoppageType.GoalieStopped, NhlDescription = "Goalie Stopped", StoppageName = "Goalie Stopped"},
                //	new RefStoppageType{ StoppageTypeId = StoppageType.Icing, NhlDescription = "Icing", StoppageName = "Icing"},
                //	new RefStoppageType{ StoppageTypeId = StoppageType.NetOff, NhlDescription = "Net Off", StoppageName = "Net Off"},
                //	new RefStoppageType{ StoppageTypeId = StoppageType.Offside, NhlDescription = "Offside", StoppageName = "Offside"},
                //	new RefStoppageType{ StoppageTypeId = StoppageType.PuckFrozen, NhlDescription = "Puck Frozen", StoppageName = "Puck Frozen"},
                //	new RefStoppageType{ StoppageTypeId = StoppageType.PuckInBenches, NhlDescription = "Puck In Benches", StoppageName = "Puck in Benches"},
                //	new RefStoppageType{ StoppageTypeId = StoppageType.PuckInCrowd, NhlDescription = "Puck In Crowd", StoppageName = "Puck in Crowd"},
                //	new RefStoppageType{ StoppageTypeId = StoppageType.PuckInNetting, NhlDescription = "Puck In Netting", StoppageName = "Puck in Netting"},
                //	new RefStoppageType{ StoppageTypeId = StoppageType.TVTimeout, NhlDescription = "TV Timeout", StoppageName = "TV timeout"},
                //});
                //context.SaveChanges();

                //context.Leagues.Add(new League { LeagueName = "National Hockey League", LeagueAbbr = "NHL" });
                //context.SaveChanges();

                //context.Players.Add(new Player { NhlPlayerId = 0, FullName = "Unknown" });
                //context.SaveChanges();

                var seasonsProcessor = new SeasonsProcessor();
                seasonsProcessor.Run(context);

                //var dbSeasons = context.Seasons.Where(x => x.SeasonId > 100 && x.NhlSeasonKey != "20192020").OrderBy(x => x.SeasonId).ToList();
                var dbSeasons = context.Seasons.Where(x => x.NhlSeasonKey == "20192020").OrderBy(x => x.SeasonId).ToList();
                //var dbSeasons = context.Seasons.OrderBy(x => x.SeasonId).ToList();
                for (int i = 0; i < dbSeasons.Count; i++)
                {
                    var dbSeason     = dbSeasons[i];
                    var nhlSeasonKey = dbSeason.NhlSeasonKey;
                    Console.WriteLine($"PROCESS TEAMS - {nhlSeasonKey}");
                    var teamsProcessor = new TeamsProcessor(nhlSeasonKey);
                    teamsProcessor.Run(context);

                    Console.WriteLine($"PROCESS GAMES - {nhlSeasonKey}");
                    var gamesProcessor = new GamesProcessor(nhlSeasonKey);
                    gamesProcessor.Run(context);

                    var seasonGames = context.Games.Where(x => x.SeasonId == dbSeason.SeasonId).ToList();
                    for (int j = 0; j < seasonGames.Count; j++)
                    {
                        Console.WriteLine($"PROCESS GAMES - {nhlSeasonKey} - BOXES: {j}/{seasonGames.Count}");
                        var seasonGame        = seasonGames[j];
                        var gameLiveProcessor = new GameLiveProcessor(seasonGame.NhlGameId, seasonGame.GameDateEst);
                        gameLiveProcessor.Run(context);

                        if (j % 30 == 29)
                        {
                            context.Dispose();
                            context = new HockeyDataContext(config);
                        }
                    }

                    if (i % 10 == 9)
                    {
                        context.Dispose();
                        context = new HockeyDataContext(config);
                    }
                }
            }
            finally
            {
                if (context != null)
                {
                    context.Dispose();
                }
            }
        }
        public override void Run()
        {
            var config = GetConfig();

            using (var context = new BasketballDataContext(config))
            {
                context.Countries.Add(
                    new Country
                {
                    ApiBasketballCountryId = 0,
                    CountryAbbr            = "XX",
                    CountryName            = "World",
                    FlagUrl = null
                });

                context.RefGameStatuses.AddRange(new List <RefGameStatus>
                {
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.NotStarted, FullGameStatusName = "Not Started", GameStatusId = GameStatus.Pregame, GameStatusName = "Pregame", ApiBasketballStatusCode = "NS"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Live_Q1, FullGameStatusName = "Live - Q1", GameStatusId = GameStatus.Live, GameStatusName = "Live", ApiBasketballStatusCode = "Q1"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Live_Q2, FullGameStatusName = "Live - Q2", GameStatusId = GameStatus.Live, GameStatusName = "Live", ApiBasketballStatusCode = "Q2"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Live_Q3, FullGameStatusName = "Live - Q3", GameStatusId = GameStatus.Live, GameStatusName = "Live", ApiBasketballStatusCode = "Q3"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Live_Q4, FullGameStatusName = "Live - Q4", GameStatusId = GameStatus.Live, GameStatusName = "Live", ApiBasketballStatusCode = "Q4"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Live_OT, FullGameStatusName = "Live - OT", GameStatusId = GameStatus.Live, GameStatusName = "Live", ApiBasketballStatusCode = "OT"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Live_BK, FullGameStatusName = "Live - Break", GameStatusId = GameStatus.Live, GameStatusName = "Live", ApiBasketballStatusCode = "BT"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Live_HT, FullGameStatusName = "Live - Halftime", GameStatusId = GameStatus.Live, GameStatusName = "Live", ApiBasketballStatusCode = "HT"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Final, FullGameStatusName = "Final", GameStatusId = GameStatus.Final, GameStatusName = "Final", ApiBasketballStatusCode = "FT"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.FinalWithOT, FullGameStatusName = "Final (OT)", GameStatusId = GameStatus.Final, GameStatusName = "Final", ApiBasketballStatusCode = "AOT"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Postponed, FullGameStatusName = "Postponed", GameStatusId = GameStatus.Postponed, GameStatusName = "Postponed", ApiBasketballStatusCode = "POST"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Cancelled, FullGameStatusName = "Cancelled", GameStatusId = GameStatus.Cancelled, GameStatusName = "Cancelled", ApiBasketballStatusCode = "CANC"
                    },
                    new RefGameStatus {
                        FullGameStatusId = FullGameStatus.Unknown, FullGameStatusName = "Unknown", GameStatusId = GameStatus.Unknown, GameStatusName = "Unknown", ApiBasketballStatusCode = null
                    }
                });
                context.SaveChanges();

                var bookmakersProcessor = new BookmakersProcessor();
                Console.WriteLine("START BOOKMAKERS");
                bookmakersProcessor.Run(context);
                Console.WriteLine("SAVE BOOKMAKERS");
                context.SaveChanges();
                Console.WriteLine("END BOOKMAKERS");

                var betTypesProcessor = new BetTypesProcessor();
                Console.WriteLine("START BET TYPES");
                betTypesProcessor.Run(context);
                Console.WriteLine("SAVE BET TYPES");
                context.SaveChanges();
                Console.WriteLine("END BET TYPES");

                var countriesProcessor = new CountriesProcessor();
                Console.WriteLine("START COUNTRIES");
                countriesProcessor.Run(context);
                Console.WriteLine("SAVE COUNTRIES");
                context.SaveChanges();
                Console.WriteLine("END COUNTRIES");

                var leaguesProcessor = new LeaguesProcessor();
                Console.WriteLine("START LEAGUES");
                leaguesProcessor.Run(context);
                Console.WriteLine("SAVE LEAGUES");
                context.SaveChanges();
                Console.WriteLine("END LEAGUES");

                var leagueSeasons = context.LeagueSeasons
                                    .OrderBy(x => x.LeagueSeasonId)
                                    .Select(y => new { y.ApiBasketballLeagueId, y.ApiBasketballSeasonKey })
                                    .ToList();

                foreach (var leagueSeason in leagueSeasons)
                {
                    int    leagueId       = leagueSeason.ApiBasketballLeagueId;
                    string seasonKey      = leagueSeason.ApiBasketballSeasonKey;
                    var    teamsProcessor = new TeamsProcessor(leagueId, seasonKey);
                    Console.WriteLine($"START TEAMS - {leagueId} {seasonKey}");
                    teamsProcessor.Run(context);
                    Console.WriteLine($"SAVE TEAMS - {leagueId} {seasonKey}");
                    context.SaveChanges();
                    Console.WriteLine($"END TEAMS - {leagueId} {seasonKey}");
                }

                var countriesDict = context.Countries.ToDictionary(x => x.ApiBasketballCountryId, y => y.CountryId);
                var teamsDict     = context.Teams.ToDictionary(x => x.ApiBasketballTeamId, y => y.TeamId);
                var statusDict    = context.RefGameStatuses
                                    .Where(x => !string.IsNullOrEmpty(x.ApiBasketballStatusCode))
                                    .ToDictionary(x => x.ApiBasketballStatusCode, y => y.FullGameStatusId);
                foreach (var leagueSeason in leagueSeasons)
                {
                    int    leagueId       = leagueSeason.ApiBasketballLeagueId;
                    string seasonKey      = leagueSeason.ApiBasketballSeasonKey;
                    var    gamesProcessor = new GamesProcessor(leagueId, seasonKey, countriesDict, statusDict);
                    Console.WriteLine($"START GAMES - {leagueId} {seasonKey}");
                    gamesProcessor.Run(context);
                    Console.WriteLine($"SAVE GAMES - {leagueId} {seasonKey}");
                    context.SaveChanges();
                    Console.WriteLine($"END GAMES - {leagueId} {seasonKey}");
                }

                var bookmakersDict = context.Bookmakers.ToDictionary(x => x.ApiBasketballBookmakerId, y => y.BookmakerId);
                var betTypesDict   = context.BetTypes.ToDictionary(x => x.ApiBasketballBetTypeId, y => y.BetTypeId);

                var liveAndUpcomingGameStatuses = context.RefGameStatuses
                                                  .Where(x => x.GameStatusId == GameStatus.Pregame || x.GameStatusId == GameStatus.Live)
                                                  .Select(x => x.FullGameStatusId)
                                                  .ToList();

                foreach (var leagueSeason in leagueSeasons)
                {
                    int    leagueId      = leagueSeason.ApiBasketballLeagueId;
                    string seasonKey     = leagueSeason.ApiBasketballSeasonKey;
                    var    oddsProcessor = new OddsProcessor(leagueId, seasonKey, betTypesDict, bookmakersDict);
                    Console.WriteLine($"START ODDS - {leagueId} {seasonKey}");
                    oddsProcessor.Run(context);
                    Console.WriteLine($"SAVE ODDS - {leagueId} {seasonKey}");
                    context.SaveChanges();
                    Console.WriteLine($"END ODDS - {leagueId} {seasonKey}");
                }
            }
        }
예제 #9
0
        public async Task <IActionResult> FetchGenres()
        {
            var filters = await GamesProcessor.FetchGenres();

            return(Json(filters.genres));
        }