コード例 #1
0
        public CompetitionLayoutIndexViewModel(CompetitionInfo info, ScoringMap scoringMap)
        {
            Info = info;
            ScoringMap = scoringMap;

            Performances =
                info
                    .Registrations
                    .SelectMany(x => x.GetPerformances(info.Competition))
                    .ToList();

            var go =
                Performances.Where(x => x.RegistrationId == "company/1/competitions/5/registrations/gyms/41/team/12").ToList();

            JudgePanel = new FiveJudgePanel(new List<JudgeScore>()); //TODO: If we need a different panel....
            SecurityContext = new SecurityContext();
        }
コード例 #2
0
        void Populate(CompetitionInfo info)
        {
            var performances =
                info.Registrations
                    .Select(x => x.GetPerformances(info.Competition))
                    .SelectMany(x => x)
                    .ToList();

            var panel = new FiveJudgePanel(new List<JudgeScore>());
            performances.ForEach(performance =>
            {
                var scores = panel.Judges.Select(judge => new JudgeScore(performance.Id, judge.Id)).ToList();
                var calculator = new FiveJudgePanelPerformanceScoreCalculator(scores);

                var score = new PerformanceScore {PerformanceId = performance.Id};
                var command = new MarkTeamScoringCompleteCommand
                {
                    PerformanceId = performance.Id,
                    RegistrationId = performance.RegistrationId,
                    DivisionId = performance.DivisionId,
                    CommandByUser = "******",
                    CommandWhen = DateTime.UtcNow
                };

                score.Update(calculator);
                score.Update(command);
                score.IsScoringComplete = false;

                scores.ForEach(RavenSession.Store);
                RavenSession.Store(score);
            });
        }
コード例 #3
0
        public IEnumerable<TeamScore> From(IEnumerable<PerformanceScore> scores, CompetitionInfo info)
        {
            var result =
                scores
                    .Select(s =>
                    {
                        var registration =
                            info.Registrations.First(x => x.Id == s.RegistrationId);

                        var gym =
                            info.Gyms.First(x => x.Id == registration.GymId);

                        var division =
                            info.Divisions.First(x => x.Id == s.DivisionId);

                        var level =
                            info.Levels.First(x => x.Id == division.LevelId);

                        var awardsLevel =
                            info.CompetitionDivisions.FindAwardsLevel(division.LevelId);

                        return new TeamScore
                        {
                            CompetitionId = info.Competition.Id,
                            RegistrationId = registration.Id,
                            LevelId = level.Id,
                            AwardsLevelId = awardsLevel.Id,
                            DivisionId = division.Id,
                            PerformanceScores = new List<decimal>(){s.TotalScore},
                            GymName = gym.Name,
                            DivisionName = division.Name,
                            LevelName = level.Name,
                            AwardsLevelName = awardsLevel.Name,
                            TeamName = registration.TeamName,
                            GymLocation = gym.Location,
                            IsSmallGym = gym.IsSmallGym,
                            IsShowTeam = registration.IsShowTeam,
                            Participants = registration.ParticipantCount,
                            DidNotCompete = s.DidNotCompete,
                            ScoringComplete = s.IsScoringComplete,
                            UseSmallGymCalculator = awardsLevel.UseSmallGymRanking,
                            SuppressLevelChampion = awardsLevel.SuppressLevelWinner
                        };
                    }
            );

            return result;
        }