public ForWebGoodThru GetDataGoodThru(int seasonId)
    {
      var results = new ForWebGoodThru() { GT = "n/a" };

      using (var context = new LO30Context())
      {
        var maxGameData = context.GoalieStatGames
                .GroupBy(x => new { x.SeasonId, x.Playoffs })
                .Select(grp => new
                {
                  SeasonId = grp.Key.SeasonId,
                  Playoffs = grp.Key.Playoffs,
                  GameId = grp.Max(x => x.GameId),
                  GameDateTime = grp.Max(x => x.Game.GameDateTime)
                })
                .Where(x => x.SeasonId == seasonId)
                .OrderByDescending(x => x.GameDateTime)
                .ToList();

        var max = maxGameData.FirstOrDefault();
        if (max != null)
        {
          results = new ForWebGoodThru() { GT = max.GameDateTime.ToShortDateString() };
        }

        return results;
      }
    }
Exemple #2
0
 public AccessImporter(LogWriter logger, LO30Context context, bool seed = true)
 {
   _logger = logger;
   _context = context;
   _lo30ContextService = new LO30ContextService(context);
   _seed = seed;
 }
    public List<ForWebTeamStanding> GetForWebTeamStandings(int seasonId, bool playoffs)
    {
      var results = new List<ForWebTeamStanding>();

      using (var context = new LO30Context())
      {
        results = context.ForWebTeamStandings.Where(x => x.SID == seasonId && x.PFS == playoffs).ToList();
      }
      return results.OrderByDescending(x => x.PTS).ToList();
    }
    public List<Setting> GetSettings()
    {
      var results = new List<Setting>();

      using (var context = new LO30Context())
      {
        results = context.Settings.ToList();
      }
      return results;
    }
    public GameRoster GetGameRosterByGameIdTeamIdAndPlayerNumber(int gameId, int teamId, string playerNumber)
    {
      var results = new GameRoster();

      using (var context = new LO30Context())
      {
        results = context.GameRosters.Where(x=>x.GameId == gameId && x.TeamId == teamId && x.PlayerNumber == playerNumber).FirstOrDefault();
      }
      return results;
    }
    public List<ForWebGoalieStat> GetForWebGoalieStats(int seasonId, bool playoffs)
    {
      var results = new List<ForWebGoalieStat>();

      using (var context = new LO30Context())
      {
        results = context.ForWebGoalieStats.Where(x => x.SID == seasonId && x.PFS == playoffs).ToList();
      }
      return results.OrderBy(x => x.GAA).ToList();
    }
    public GameRoster GetByGameRosterId(int gameRosterId)
    {
      var results = new GameRoster();

      using (var context = new LO30Context())
      {
        results = context.GameRosters.Where(x => x.GameRosterId == gameRosterId).FirstOrDefault();
      }
      return results;
    }
    public IEnumerable<Game> GetAllGames()
    {
      List<Game> games;

      using (var context = new LO30Context())
      {
        games = context.Games.ToList();
      }

      return games;
    }
    public List<Season> ListSeasons()
    {
      var results = new List<Season>();
      using (var context = new LO30Context())
      {
        results = context.Seasons
                          .Where(x=>x.SeasonId > 0)
                          .ToList();
      }

      return results.OrderByDescending(x => x.SeasonName).ToList();
    }
    public List<PlayerStatus> GetPlayerStatuses()
    {
      var results = new List<PlayerStatus>();

      using (var context = new LO30Context())
      {
        results = context.PlayerStatuses
                          .IncludeAll()
                          .ToList();
      }
      return results;
    }
    public GoalieStatGame GetGoalieStatGameByPlayerIdGameId(int playerId, int gameId)
    {
      var results = new GoalieStatGame();

      using (var context = new LO30Context())
      {
        results = context.GoalieStatGames
                          .Where(x => x.PlayerId == playerId && x.GameId == gameId)
                          .IncludeAll()
                          .SingleOrDefault();
      }
      return results;
    }
    public PlayerStatTeam GetPlayerStatTeamByPlayerIdTeamId(int playerId, int teamId, bool playoffs)
    {
      var results = new PlayerStatTeam();

      using (var context = new LO30Context())
      {
        results = context.PlayerStatTeams
                          .Where(x => x.PlayerId == playerId && x.TeamId == teamId && x.Playoffs == playoffs)
                          .IncludeAll()
                          .SingleOrDefault();
      }
      return results;
    }
    public PlayerStatCareer GetPlayerStatCareerByPlayerId(int playerId)
    {
      var results = new PlayerStatCareer();

      using (var context = new LO30Context())
      {
        results = context.PlayerStatCareers
                          .Where(x => x.PlayerId == playerId)
                          .IncludeAll()
                          .SingleOrDefault();
      }
      return results;
    }
    public GameTeam GetGameTeamByGameIdAndHomeTeam(int gameId, bool homeTeam)
    {
      var results = new GameTeam();

      using (var context = new LO30Context())
      {
        results = context.GameTeams
                          .Where(x => x.GameId == gameId && x.HomeTeam == homeTeam)
                          .IncludeAll()
                          .FirstOrDefault();
      }
      return results;
    }
    public PlayerStatSeason GetPlayerStatSeasonByPlayerIdSeasonIdPlayoffs(int playerId, int seasonId, bool playoffs)
    {
      var results = new PlayerStatSeason();

      using (var context = new LO30Context())
      {
        results = context.PlayerStatSeasons
                          .Where(x => x.PlayerId == playerId && x.SeasonId == seasonId && x.Playoffs == playoffs)
                          .IncludeAll()
                          .SingleOrDefault();
      }
      return results;
    }
    public GoalieStatSeason GetGoalieStatSeasonByPlayerIdSeasonIdSub(int playerId, int seasonId, bool playoffs, bool sub)
    {
      var results = new GoalieStatSeason();

      using (var context = new LO30Context())
      {
        results = context.GoalieStatSeasons
                          .Where(x => x.PlayerId == playerId && x.SeasonId == seasonId && x.Playoffs == playoffs && x.Sub == sub)
                          .IncludeAll()
                          .SingleOrDefault();
      }
      return results;
    }
Exemple #17
0
    public Game GetGamesByGameId(int gameId)
    {
      var results = new Game();

      using (var context = new LO30Context())
      {
        results = context.Games
                          .Where(x => x.GameId == gameId)
                          .IncludeAll()
                          .FirstOrDefault();
      }
      return results;
    }
    public TeamRoster GetTeamRosterByTeamIdYYYYMMDDAndPlayerId(int teamId, int yyyymmdd, int playerId)
    {
      var results = new TeamRoster();

      using (var context = new LO30Context())
      {
        results = context.TeamRosters.Where(x => x.TeamId == teamId && 
          x.StartYYYYMMDD <= yyyymmdd && 
          x.EndYYYYMMDD >= yyyymmdd &&
          x.PlayerId == playerId).IncludeAll().FirstOrDefault();
      }
      return results;
    }
    public List<GameTeam> GetGameTeamsByGameId(int gameId)
    {
      var results = new List<GameTeam>();

      using (var context = new LO30Context())
      {
        results = context.GameTeams
                          .Where(x=>x.GameId == gameId)
                          .IncludeAll()
                          .ToList();
      }
      return results;
    }
    public List<ScoreSheetEntryProcessedGoal> GetScoreSheetEntriesProcessedByGameId(int gameId)
    {
      var results = new List<ScoreSheetEntryProcessedGoal>();

      using (var context = new LO30Context())
      {
        results = context.ScoreSheetEntryProcessedGoals.Where(x => x.GameId == gameId).IncludeAll().ToList();
      }
      return results.OrderBy(x => x.GameId)
                    .ThenBy(x => x.Period)
                    .ThenByDescending(x => x.TimeRemaining)
                    .ToList();
    }
    public GameOutcome GetGameOutcomeByGameIdAndHomeTeam(int gameId, bool homeTeam, bool fullDetail = true)
    {
      var results = new GameOutcome();

      using (var context = new LO30Context())
      {
        results = context.GameOutcomes
                          .Where(x => x.GameId == gameId && x.HomeTeam == homeTeam)
                          .IncludeAll()
                          .FirstOrDefault();
      }
      return results;
    }
    public List<ScoreSheetEntryProcessedPenalty> GetScoreSheetEntryPenaltiesProcessed()
    {
      var results = new List<ScoreSheetEntryProcessedPenalty>();

      using (var context = new LO30Context())
      {
        results = context.ScoreSheetEntryProcessedPenalties.IncludeAll().ToList();
      }
      return results.OrderBy(x => x.GameId)
                    .ThenBy(x => x.Period)
                    .ThenByDescending(x => x.TimeRemaining)
                    .ToList();
    }
    public List<GameOutcome> GetGameOutcomes()
    {
      var results = new List<GameOutcome>();

      using (var context = new LO30Context())
      {
        results = context.GameOutcomes
                          .IncludeAll()
                          .ToList();
      }
      return results.OrderByDescending(x => x.GameId)
                    .ToList();
    }
    public GameTeam GetGameTeamByGameAndTeamId(int gameId, int teamId)
    {
      var results = new GameTeam();

      using (var context = new LO30Context())
      {
        results = context.GameTeams
                          .Where(x=>x.GameId == gameId && x.TeamId == teamId)
                          .IncludeAll()
                          .FirstOrDefault();
      }
      return results;
    }
    public List<GameOutcome> GetGameOutcomesByGameId(int gameId, bool fullDetail = true)
    {
      var results = new List<GameOutcome>();

      using (var context = new LO30Context())
      {
        results = context.GameOutcomes
                          .Where(x=>x.GameId == gameId)
                          .IncludeAll()
                          .ToList();
      }
      return results.OrderByDescending(x => x.GameId)
                    .ToList();
    }
    public List<PlayerStatGame> GetPlayerStatsGame()
    {
      var results = new List<PlayerStatGame>();

      using (var context = new LO30Context())
      {
        results = context.PlayerStatGames
                          .IncludeAll()
                          .ToList();
      }
      return results.OrderBy(x => x.Player.LastName)
               .ThenBy(x => x.Player.FirstName)
               .ToList();
    }
    public ActionResult Delete(int id, bool? exception, string exceptionMessage)
    {
      if (exception.HasValue)
      {
        ViewBag.ErrorMessage = "Unable to perform action.  Exception:" + exceptionMessage;
      }

      var setting = new Setting();
      using (var context = new LO30Context())
      {
        setting = context.Settings.Where(x => x.SettingId == id).FirstOrDefault();
      }
      return View(setting);
    }
    public List<GoalieStatTeam> GetGoalieStatsTeam()
    {
      var results = new List<GoalieStatTeam>();

      using (var context = new LO30Context())
      {
        results = context.GoalieStatTeams
                          .IncludeAll()
                          .ToList();
      }
      return results.OrderBy(x => x.Player.LastName)
                    .ThenBy(x=>x.Player.FirstName)
                    .ToList();
    }
    public List<PlayerStatGame> GetPlayerStatsGameByPlayerIdSeasonId(int playerId, int seasonId)
    {
      var results = new List<PlayerStatGame>();

      using (var context = new LO30Context())
      {
        results = context.PlayerStatGames
                          .Where(x => x.PlayerId == playerId && x.SeasonId == seasonId)
                          .IncludeAll()
                          .ToList();
      }
      return results.OrderBy(x => x.Player.LastName)
               .ThenBy(x => x.Player.FirstName)
               .ToList();
    }
    public List<TeamRoster> GetTeamRostersByTeamIdAndYYYYMMDD(int teamId, int yyyymmdd)
    {
      var results = new List<TeamRoster>();

      using (var context = new LO30Context())
      {
        results = context.TeamRosters.Where(x => x.TeamId == teamId && x.StartYYYYMMDD <= yyyymmdd && x.EndYYYYMMDD >= yyyymmdd).IncludeAll().ToList();
      }
      return results.OrderByDescending(x => x.SeasonId)
                    .ThenByDescending(x => x.TeamId)
                    .ThenBy(x => x.StartYYYYMMDD)
                    .ThenBy(x => x.EndYYYYMMDD)
                    .ThenBy(x => x.PlayerNumber)
                    .ToList();
    }