Esempio n. 1
0
 private static IEnumerable<object> GetPlayerSeasonData(Player player, int year)
 {
     return from sl in player.StatLines
            where sl.GameParticipant.Game.GameDate.Year == year
            orderby sl.GameParticipant.Game.GameDate
            let opponent = sl.GameParticipant
                             .Game
                             .GameParticipants
                             .Single(gp => gp.GameParticipantId != sl.GameParticipantId)
                             .TeamYear
            select new PlayerSeasonStatisticsRowModel
                   {
                       GameId = sl.GameParticipant.GameId,
                       GameDate = sl.GameParticipant.Game.GameDate.ToString(Consts.DateFormat),
                       Year = (YearEnum)year,
                       Opponent = new StatisticsTeamInfoModel
                              {
                                  TeamId = opponent.TeamId,
                                  TeamName = opponent.FullName
                              },
                       PlateAppearances = sl.StatPlateAppearances,
                       AtBats = sl.StatAtBats,
                       Hits = sl.StatHits,
                       TotalBases = sl.StatTotalBases,
                       Runs = sl.StatRuns,
                       RunsBattedIn = sl.StatRunsBattedIn,
                       Singles = sl.StatSingles,
                       Doubles = sl.StatDoubles,
                       Triples = sl.StatTriples,
                       HomeRuns = sl.StatHomeRuns,
                       Walks = sl.StatWalks,
                       SacrificeFlies = sl.StatSacrificeFlies,
                       Outs = sl.StatOuts,
                       FieldersChoices = sl.StatFieldersChoices,
                       ReachedByErrors = sl.StatReachedByErrors,
                       Strikeouts = sl.StatStrikeouts
                   };
 }
Esempio n. 2
0
 private static IEnumerable<object> GetPlayerCareerData(Player player)
 {
     return player.StatLines
                  .GroupBy(sl => sl.GameParticipant.Game.GameDate.Year)
                  .Select(slg => new PlayerCareerStatisticsRowModel
                                 {
                                     Year = (YearEnum)slg.Key,
                                     Player = new StatisticsPlayerInfoModel
                                              {
                                                  PlayerId = player.PlayerId
                                              },
                                     Games = slg.Count(),
                                     PlateAppearances = slg.Sum(sl => sl.StatPlateAppearances),
                                     AtBats = slg.Sum(sl => sl.StatAtBats),
                                     Hits = slg.Sum(sl => sl.StatHits),
                                     TotalBases = slg.Sum(sl => sl.StatTotalBases),
                                     Runs = slg.Sum(sl => sl.StatRuns),
                                     RunsBattedIn = slg.Sum(sl => sl.StatRunsBattedIn),
                                     Singles = slg.Sum(sl => sl.StatSingles),
                                     Doubles = slg.Sum(sl => sl.StatDoubles),
                                     Triples = slg.Sum(sl => sl.StatTriples),
                                     HomeRuns = slg.Sum(sl => sl.StatHomeRuns),
                                     Walks = slg.Sum(sl => sl.StatWalks),
                                     SacrificeFlies = slg.Sum(sl => sl.StatSacrificeFlies),
                                     Outs = slg.Sum(sl => sl.StatOuts),
                                     FieldersChoices = slg.Sum(sl => sl.StatFieldersChoices),
                                     ReachedByErrors = slg.Sum(sl => sl.StatReachedByErrors),
                                     Strikeouts = slg.Sum(sl => sl.StatStrikeouts)
                                 });
 }