Exemplo n.º 1
0
        public long AddGame(Game game)
        {
            long id;

            using (var conn = GetConnection())
            {
                var cmd = new MySqlCommand(INSERT_GAME, conn);

                cmd.Parameters.AddWithValue("@season", game.Season);
                cmd.Parameters.AddWithValue("@type", game.SeasonType);
                cmd.Parameters.AddWithValue("@week", game.Week);
                cmd.Parameters.AddWithValue("@gameTime", game.GameTime);
                cmd.Parameters.AddWithValue("@homeTeamId", game.HomeTeam.Id);
                cmd.Parameters.AddWithValue("@awayTeamId", game.AwayTeam.Id);
                cmd.Parameters.AddWithValue("@awayTeamPoints", game.AwayTeamScore);
                cmd.Parameters.AddWithValue("@homeTeamPoints", game.HomeTeamScore);
                cmd.Parameters.AddWithValue("@winningTeamId", game.WinningTeamId);
                cmd.Parameters.AddWithValue("@isGameOver", game.IsGameOver);
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
                id = cmd.LastInsertedId;
            }

            return id;
        }
Exemplo n.º 2
0
        private Game CreateNewGame(NflDotComGame nflDotComGame, Dictionary<string, Team> teamsDictionary)
        {
            var game = new Game
                {
                    AwayTeamScore = nflDotComGame.AwayScore,
                    GameTime = nflDotComGame.DateTime,
                    HomeTeamScore = nflDotComGame.HomeScore,
                    IsGameOver = nflDotComGame.IsFinal,
                    Season = nflDotComGame.Season,
                    Week = nflDotComGame.WeekNumber
                };

            if (nflDotComGame.AwayTeam != null && !String.IsNullOrWhiteSpace(nflDotComGame.AwayTeam.Abbreviation))
            {
                Team sportPicksTeam;

                if (teamsDictionary.TryGetValue(nflDotComGame.AwayTeam.Abbreviation.ToUpper(), out sportPicksTeam))
                {
                    game.AwayTeam = sportPicksTeam;
                }
            }

            if (nflDotComGame.HomeTeam != null && !String.IsNullOrWhiteSpace(nflDotComGame.HomeTeam.Abbreviation))
            {
                Team sportPicksTeam;

                if (teamsDictionary.TryGetValue(nflDotComGame.HomeTeam.Abbreviation.ToUpper(), out sportPicksTeam))
                {
                    game.HomeTeam = sportPicksTeam;
                }
            }

            if (nflDotComGame.Winner != null && !String.IsNullOrWhiteSpace(nflDotComGame.Winner.Abbreviation))
            {
                Team sportPicksTeam;

                if (teamsDictionary.TryGetValue(nflDotComGame.Winner.Abbreviation.ToUpper(), out sportPicksTeam))
                {
                    game.WinningTeamId = sportPicksTeam.Id;
                }
            }

            return game;
        }
Exemplo n.º 3
0
 private static bool IsGameMatchingBySeasonWeekAndParticipants(Game game, NflDotComGame nflDotComGame)
 {
     return game.Season == nflDotComGame.Season
            && game.Week == nflDotComGame.WeekNumber
            && game.HomeTeam.Abbreviation.ToUpper() == nflDotComGame.HomeTeam.Abbreviation.ToUpper()
            && game.AwayTeam.Abbreviation.ToUpper() == nflDotComGame.AwayTeam.Abbreviation.ToUpper();
 }
Exemplo n.º 4
0
 public long AddGame(Game game)
 {
     return _gameRepository.AddGame(game);
 }
Exemplo n.º 5
0
 private void PopulateTeamsForGame(Game game)
 {
     _teams = _teams ?? _teamRepository.GetAll();
     game.AwayTeam = _teams.FirstOrDefault(team => team.Id == game.AwayTeam.Id);
     game.HomeTeam = _teams.FirstOrDefault(team => team.Id == game.HomeTeam.Id);
 }
Exemplo n.º 6
0
 public void UpdateGame(Game game)
 {
     _gameRepository.UpdateGame(game);
 }
 private static bool IsGameMatchingBySeasonWeekTypeAndParticipants(Game game, FantasyDataGame fantasyDataGame)
 {
     return game.Season == fantasyDataGame.Season
            && (int) game.SeasonType == fantasyDataGame.SeasonType
            && game.Week == fantasyDataGame.Week
            && game.HomeTeam.Abbreviation.ToUpper() == fantasyDataGame.HomeTeam.ToUpper()
            && game.AwayTeam.Abbreviation.ToUpper() == fantasyDataGame.AwayTeam.ToUpper();
 }
        private static Game CreateNewGame(FantasyDataGame fantasyDataGame, Dictionary<string, Team> teamsDictionary)
        {
            var game = new Game
                {
                    AwayTeamScore = fantasyDataGame.AwayScore,
                    GameTime = fantasyDataGame.Date,
                    HomeTeamScore = fantasyDataGame.HomeScore,
                    IsGameOver = fantasyDataGame.IsOver,
                    Season = fantasyDataGame.Season,
                    SeasonType = (SeasonType) fantasyDataGame.SeasonType,
                    Week = fantasyDataGame.Week
                };

            if (!String.IsNullOrWhiteSpace(fantasyDataGame.AwayTeam))
            {
                Team sportPicksTeam;

                if (teamsDictionary.TryGetValue(fantasyDataGame.AwayTeam.ToUpper(), out sportPicksTeam))
                {
                    game.AwayTeam = sportPicksTeam;
                }
            }

            if (!String.IsNullOrWhiteSpace(fantasyDataGame.HomeTeam))
            {
                Team sportPicksTeam;

                if (teamsDictionary.TryGetValue(fantasyDataGame.HomeTeam.ToUpper(), out sportPicksTeam))
                {
                    game.HomeTeam = sportPicksTeam;
                }
            }

            if (fantasyDataGame.WinningTeam != null && !String.IsNullOrWhiteSpace(fantasyDataGame.WinningTeam))
            {
                Team sportPicksTeam;

                if (teamsDictionary.TryGetValue(fantasyDataGame.WinningTeam.ToUpper(), out sportPicksTeam))
                {
                    game.WinningTeamId = sportPicksTeam.Id;
                }
            }

            return game;
        }
Exemplo n.º 9
0
        private static Game MapGame(MySqlDataReader dr)
        {
            var game = new Game
                {
                    AwayTeam = new Team
                    {
                        Id = dr.GetInt32("awayTeamId"),
                    },
                    GameTime = dr.GetDateTime("gameTime"),
                    HomeTeam = new Team
                    {
                        Id = dr.GetInt32("homeTeamId")
                    },
                    Id = dr.GetInt64("id"),
                    IsGameOver = dr.GetBoolean("isGameOver"),
                    Season = dr.GetInt32("season"),
                    SeasonType = (SeasonType) dr.GetInt32("type"),
                    Week = dr.GetInt32("week")
                };

            if (dr["awayTeamPoints"] != DBNull.Value)
            {
                game.AwayTeamScore = dr.GetInt32("awayTeamPoints");
            }

            if (dr["homeTeamPoints"] != DBNull.Value)
            {
                game.HomeTeamScore = dr.GetInt32("homeTeamPoints");
            }

            if (dr["winningTeamId"] != DBNull.Value)
            {
                game.WinningTeamId = dr.GetInt32("winningTeamId");
            }

            game.GameTime = game.GameTime.AddDays(ConfigSettings.GameTimeOffSetInDays);

            return game;
        }
Exemplo n.º 10
0
        public void UpdateGame(Game game)
        {
            using (var conn = GetConnection())
            {
                var cmd = new MySqlCommand(UPDATE_GAME, conn);

                cmd.Parameters.AddWithValue("@season", game.Season);
                cmd.Parameters.AddWithValue("@week", game.Week);
                cmd.Parameters.AddWithValue("@type", game.SeasonType);
                cmd.Parameters.AddWithValue("@gameTime", game.GameTime);
                cmd.Parameters.AddWithValue("@homeTeamId", game.HomeTeam.Id);
                cmd.Parameters.AddWithValue("@awayTeamId", game.AwayTeam.Id);
                cmd.Parameters.AddWithValue("@awayTeamPoints", game.AwayTeamScore);
                cmd.Parameters.AddWithValue("@homeTeamPoints", game.HomeTeamScore);
                cmd.Parameters.AddWithValue("@winningTeamId", game.WinningTeamId);
                cmd.Parameters.AddWithValue("@isGameOver", game.IsGameOver);
                cmd.Parameters.AddWithValue("@id", game.Id);
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
            }
        }
Exemplo n.º 11
0
        private static List<Game> CreateGames(int? winningTeamId)
        {
            var games = new List<Game>();
            var game = new Game
                {
                    AwayTeam = new Team
                        {
                            Id = AWAY_TEAM_ID
                        },
                    HomeTeam = new Team
                        {
                            Id = HOME_TEAM_ID
                        },
                    IsGameOver = true,
                    WinningTeamId = winningTeamId
                };

            games.Add(game);

            return games;
        }