public NhlGameDto GetGame(int id) { NhlGameDto game = null; if (m_Games.TryGetValue(id, out game)) { return(game); } return(game); }
public static NhlGame CreateNhlGameFromNhlGameDto(NhlGameDto nhlGameDto, bool loadPlayers, Container dependencyInjectionContainer) { NhlGame nhlGame = dependencyInjectionContainer.GetInstance <NhlGame>(); nhlGame.GameId = nhlGameDto.GameId; nhlGame.StartDateTime = nhlGameDto.StartDateTime; nhlGame.Started = nhlGameDto.Started; nhlGame.HomeTeam = CreateTeamFromTeamDto(nhlGameDto.HomeTeam, loadPlayers); nhlGame.AwayTeam = CreateTeamFromTeamDto(nhlGameDto.AwayTeam, loadPlayers); if (loadPlayers) { AssignPlayerNumbers(nhlGame.HomeTeam.PlayerList, nhlGame.AwayTeam.PlayerList); } return(nhlGame); }
public NHLFakeData() { NhlGameDto b = new NhlGameDto(); b.awayScore = 3; b.awayShots = 30; b.awayTeamCity = "AWAYCITY"; b.awayTeamName = "AWAYNAME"; b.gameId = 1; b.homeScore = 4; b.homeShots = 40; b.homeTeamCity = "HOMECITY"; b.homeTeamName = "HOMENAME"; b.startTime = DateTime.Now; m_Games.Add(b.gameId, b); }
private NhlGameDto CreateGameDtoWithoutPlayers(NhlShortGame nhlShortGame) { Guid gameId = nhlShortGame.GameId; DateTime startDateTime = nhlShortGame.StartDateTime; Guid homeTeamId = nhlShortGame.HomeTeamId; Guid awayTeamId = nhlShortGame.AwayTeamId; TeamDto homeTeam = GetTeam(homeTeamId); TeamDto awayTeam = GetTeam(awayTeamId); NhlGameDto nhlGameDto = new NhlGameDto { GameId = gameId, StartDateTime = startDateTime, HomeTeam = homeTeam, AwayTeam = awayTeam }; return(nhlGameDto); }
private NhlGameDto CreateGameDtoWithPlayers(NhlShortGame nhlShortGame) { Guid gameId = nhlShortGame.GameId; DateTime startDateTime = nhlShortGame.StartDateTime; Guid homeTeamId = nhlShortGame.HomeTeamId; Guid awayTeamId = nhlShortGame.AwayTeamId; TeamDto homeTeam = GetTeam(homeTeamId); TeamDto awayTeam = GetTeam(awayTeamId); List <PlayerDto> homePlayerList = GetPlayers(homeTeamId); List <PlayerDto> awayPlayerList = GetPlayers(awayTeamId); if (homePlayerList == null || homePlayerList.Count == 0) { Logger.Info("CreateGameDtoWithPlayers() error: homePlayerList is null or empty"); } if (awayPlayerList == null || awayPlayerList.Count == 0) { Logger.Info("CreateGameDtoWithPlayers() error: awayPlayerList is null or empty"); } homeTeam.PlayerList = homePlayerList; awayTeam.PlayerList = awayPlayerList; NhlGameDto nhlGameDto = new NhlGameDto { GameId = gameId, StartDateTime = startDateTime, HomeTeam = homeTeam, AwayTeam = awayTeam }; return(nhlGameDto); }
public bool UpdateGame(int id, NhlGameDto item) { m_Games[id] = item; return(true); }
public bool AddGame(NhlGameDto item) { m_Games.Add(item.gameId, item); return(true); }
public List <NhlGameDto> GetGames(int numberGameDays, bool loadPlayers) { lock (_lockObject) { // // loadPlayers = true; List <NhlShortGame> nhlShortGameList = new List <NhlShortGame>(); List <NhlGameDto> nhlGameDtoList = new List <NhlGameDto>(); using (NpgsqlConnection npgsqlConnection = new NpgsqlConnection(ConnectionString)) { npgsqlConnection.Open(); // const string sqlCommandText = "select * from nhl.get_games(@number_game_days)"; const string sqlCommandText = @"select * from nhl.game where date(start_time - interval '8 hour') >= date(timezone('utc', now() - interval '10 hour')) and date(start_time - interval '8 hour') <= date(start_time + interval '3 Day' - interval '8 hour') order by start_time asc limit 10;"; using (NpgsqlCommand npgsqlCommand = new NpgsqlCommand(sqlCommandText, npgsqlConnection)) { npgsqlCommand.CommandType = CommandType.Text; NpgsqlParameter npgsqlParameter1 = new NpgsqlParameter("number_game_days", numberGameDays); npgsqlCommand.Parameters.Add(npgsqlParameter1); using (NpgsqlDataReader npgsqlDataReader = npgsqlCommand.ExecuteReader()) { if (!npgsqlDataReader.HasRows) { const string message = "GetGames() has no rows"; Logger.Info(message); return(nhlGameDtoList); } while (npgsqlDataReader.Read()) { Guid gameId = npgsqlDataReader.GetGuid("game_id"); DateTime startDateTime = npgsqlDataReader.GetDateTime("start_time"); Guid homeTeamId = npgsqlDataReader.GetGuid("home_id"); Guid awayTeamId = npgsqlDataReader.GetGuid("away_id"); NhlShortGame nhlShortGame = new NhlShortGame { GameId = gameId, StartDateTime = startDateTime, HomeTeamId = homeTeamId, AwayTeamId = awayTeamId }; nhlShortGameList.Add(nhlShortGame); } } } } foreach (NhlShortGame nhlShortGame in nhlShortGameList) { NhlGameDto nhlGameDto = CreateGameDto(nhlShortGame, loadPlayers); nhlGameDtoList.Add(nhlGameDto); } return(nhlGameDtoList); } }