public void Add(PlayerRivalryStatistics model)
 {
     using (var context = new BolfTrackerContext())
     {
         context.PlayerRivalryStatistics.Attach(model);
         context.Entry(model).State = EntityState.Added;
         context.SaveChanges();
     }
 }
 public void Delete(PlayerRivalryStatistics model)
 {
     throw new NotImplementedException();
 }
        public void CalculatePlayerRivalryStatistics(int gameId)
        {
            DeletePlayerRivalryStatistics(gameId);

            var shots = _shotRepository.GetByGame(gameId);

            foreach (var shot in shots)
            {
                if (shot.ShotType.Id >= 3) // TODO: This is probably not future proof
                {
                    var currentHoleShots = shots.Where(s => s.Hole.Id == shot.Hole.Id && s.Id < shot.Id).OrderByDescending(s => s.Id);
                    var affectedShot = currentHoleShots.First(s => s.ShotMade);

                    var playerRivalryStatistic = new PlayerRivalryStatistics();
                    playerRivalryStatistic.Game = shot.Game;
                    playerRivalryStatistic.Player = shot.Player;
                    playerRivalryStatistic.AffectedPlayer = affectedShot.Player;
                    playerRivalryStatistic.Hole = shot.Hole;
                    playerRivalryStatistic.ShotType = shot.ShotType;
                    playerRivalryStatistic.Attempts = shot.Attempts;
                    playerRivalryStatistic.Points = shot.Points;

                    _playerRivalryStatisticsRepository.Add(playerRivalryStatistic);
                }
            }
        }