public void Update(Event theEvent, Gender gender)
        {
            var orderedScores = GetOrderedScores(theEvent);

            if (theEvent.Reverse)
                orderedScores.Reverse();

            var i = 1;
            Score previousScore = null;
            foreach (var orderedScore in orderedScores)
            {
                if (previousScore != null &&
                    orderedScore.Time.Minutes == previousScore.Time.Minutes
                    && orderedScore.Time.Seconds == previousScore.Time.Seconds
                    && orderedScore.Reps == previousScore.Reps
                    && orderedScore.Weight == previousScore.Weight
                    && orderedScore.ScoredPlace == previousScore.ScoredPlace)
                    orderedScore.Place = previousScore.Place;
                else
                    orderedScore.Place = i;

                session.Store((Score) orderedScore);
                previousScore = orderedScore;
                i++;
            }
        }
 private Score CreateNewScore(LogScoreViewModel request, Event theEvent)
 {
     var athlete = session.Load<Athlete>(request.Athlete.Id);
     return new Score
                 {
                     AthleteId = athlete.Id,
                     EventId = theEvent.Id,
                     ScoreType = theEvent.ScoreType,
                     AthleteName = athlete.Name
                 };
 }
        private List<Score> GetOrderedScores(Event theEvent)
        {
            var scores = session
                .Query<Score>()
                .Customize(q => q.WaitForNonStaleResultsAsOfLastWrite())
                .Where(s => s.EventId == theEvent.Id)
                .ToList();

            var orderedScores = scores
                .OrderBy(s => s.Time.Minutes)
                .ThenBy(s => s.Time.Seconds)
                .ThenByDescending(s => s.Reps)
                .ThenByDescending(s => s.Weight)
                .ThenBy(s => s.ScoredPlace)
                .ToList();
            return orderedScores;
        }
        private void UpdatePlaces(Event theEvent)
        {
            var scores = session
                            .Query<Score>()
                            .Customize(q => q.WaitForNonStaleResultsAsOfLastWrite())
                            .Where(s => s.EventId == theEvent.Id)
                            .ToList();

            var orderedScores = scores
                                .OrderBy(s => s.Time.Minutes)
                                .ThenBy(s => s.Time.Seconds)
                                .ThenByDescending(s => s.Reps)
                                .ThenByDescending(s => s.Weight)
                                .ThenBy(s => s.ScoredPlace)
                                .ToList();

            if (theEvent.Reverse)
            {
                orderedScores.Reverse();
            }

            var i = 1;
            Score previousScore = null;
            foreach (var orderedScore in orderedScores)
            {
                if (previousScore != null &&
                    orderedScore.Time.Minutes == previousScore.Time.Minutes
                    && orderedScore.Time.Seconds == previousScore.Time.Seconds
                    && orderedScore.Reps == previousScore.Reps
                    && orderedScore.Weight == previousScore.Weight
                    && orderedScore.ScoredPlace == previousScore.ScoredPlace)
                    orderedScore.Place = previousScore.Place;
                else
                    orderedScore.Place = i;

                session.Store((Score) orderedScore);
                previousScore = orderedScore;
                i++;
            }
        }