public void Delete(PlayerCareerStatistics model)
 {
     using (var context = new BolfTrackerContext())
     {
         context.PlayerCareerStatistics.Remove(model);
         context.SaveChanges();
     }
 }
 public PlayerViewModel(int month, int year, Player player, IEnumerable<PlayerStatistics> playerStatistics, PlayerCareerStatistics playerCareerStatistics, IEnumerable<PlayerHoleStatistics> playerHoleStatistics)
 {
     Month = month;
     Year = year;
     Player = player;
     _playerStatistics = playerStatistics;
     PlayerCareerStatistics = playerCareerStatistics;
     PlayerHoleStatistics = playerHoleStatistics;
 }
 public void Add(PlayerCareerStatistics model)
 {
     using (var context = new BolfTrackerContext())
     {
         context.PlayerCareerStatistics.Attach(model);
         context.Entry(model).State = EntityState.Added;
         context.SaveChanges();
     }
 }
        private PlayerCareerStatistics CalculatePlayerCareerStatistics(Player player, IEnumerable<PlayerGameStatistics> playerGameStatistics)
        {
            var playerCareerStatistics = new PlayerCareerStatistics() { Player = player };

            playerCareerStatistics.Wins = playerGameStatistics.Count(pgs => pgs.Winner);
            playerCareerStatistics.Losses = playerGameStatistics.Count(pgs => !pgs.Winner);
            playerCareerStatistics.WinningPercentage = Decimal.Round((decimal)playerCareerStatistics.Wins / (decimal)playerCareerStatistics.TotalGames, 3, MidpointRounding.AwayFromZero);
            playerCareerStatistics.ShotsMade = playerGameStatistics.Sum(pgs => pgs.ShotsMade);
            playerCareerStatistics.Attempts = playerGameStatistics.Sum(pgs => pgs.Attempts);
            playerCareerStatistics.ShotsMissed = playerCareerStatistics.Attempts - playerCareerStatistics.ShotsMade;
            playerCareerStatistics.ShootingPercentage = Decimal.Round((decimal)playerCareerStatistics.ShotsMade / (decimal)playerCareerStatistics.Attempts, 3, MidpointRounding.AwayFromZero);
            playerCareerStatistics.Points = playerGameStatistics.Sum(pgs => pgs.Points);
            playerCareerStatistics.PointsPerGame = Decimal.Round((decimal)playerCareerStatistics.Points / (decimal)playerCareerStatistics.TotalGames, 1, MidpointRounding.AwayFromZero);
            playerCareerStatistics.Pushes = playerGameStatistics.Sum(pgs => pgs.Pushes);
            playerCareerStatistics.PushesPerGame = Decimal.Round((decimal)playerCareerStatistics.Pushes / (decimal)playerCareerStatistics.TotalGames, 1, MidpointRounding.AwayFromZero);
            playerCareerStatistics.Steals = playerGameStatistics.Sum(pgs => pgs.Steals);
            playerCareerStatistics.StealsPerGame = Decimal.Round((decimal)playerCareerStatistics.Steals / (decimal)playerCareerStatistics.TotalGames, 1, MidpointRounding.AwayFromZero); ;
            playerCareerStatistics.SugarFreeSteals = playerGameStatistics.Sum(pgs => pgs.SugarFreeSteals);
            playerCareerStatistics.SugarFreeStealsPerGame = Decimal.Round((decimal)playerCareerStatistics.SugarFreeSteals / (decimal)playerCareerStatistics.TotalGames, 1, MidpointRounding.AwayFromZero);
            playerCareerStatistics.StainlessSteals = playerGameStatistics.Sum(pgs => pgs.StainlessSteals);
            playerCareerStatistics.StainlessStealsPerGame = Decimal.Round((decimal)playerCareerStatistics.StainlessSteals / (decimal)playerCareerStatistics.TotalGames, 1, MidpointRounding.AwayFromZero);
            playerCareerStatistics.GameWinningSteals = playerGameStatistics.Count(pgs => pgs.GameWinningSteal);
            playerCareerStatistics.OvertimeWins = playerGameStatistics.Count(pgs => pgs.OvertimeWin);
            playerCareerStatistics.RegulationWins = playerGameStatistics.Count(pgs => !pgs.OvertimeWin && pgs.Winner);
            playerCareerStatistics.Shutouts = playerGameStatistics.Count(pgs => pgs.Shutout);
            playerCareerStatistics.PerfectGames = playerGameStatistics.Count(pgs => pgs.PerfectGame);

            return playerCareerStatistics;
        }