Exemplo n.º 1
0
 public void GivenIHaveASetOfPerformances(Table table)
 {
     var performances = table.CreateSet<PerformanceScore>().ToList();
     var generator = new TeamScoreGenerator();
     var scores = generator.From(performances, null);
     _reporting = new TeamScoreReporting(scores);
 }
        public ActionResult TwoPerformance(string id)
        {
            var performances =
                RavenSession
                    .LoadStartingWith<PerformanceScore>(id + "/scores/")
                    .ToList();

            var info =
                RavenSession
                    .Load<CompetitionInfo>(id);

            var registrations =
                info.Registrations
                    .Where(x => x.GetPerformances(info.Competition).Count() == 2)
                    .Select(x => x.Id)
                    .ToList();

            performances = performances.Where(x => registrations.Contains(x.RegistrationId)).ToList();
            var firsts = performances.Where(x => x.IsFirstPerformance);
            var seconds = performances.Where(x => x.IsSecondPerformance);

            var generator = new TeamScoreGenerator();
            var scores = generator.From(firsts, info).ToList();
            scores.ForEach(x =>
            {
                x.FirstScorePercentage = info.FirstPerformancePercentage;

                var second = seconds.FirstOrDefault(s => s.RegistrationId == x.RegistrationId);
                var total = 0.0M;
                if (second != null)
                {
                    //TODO: for worlds, switch division/level to "Worlds"
                    total = second.TotalScore;
                }

                x.PerformanceScores.Add(total);
            });

            var reporting = new TeamScoreReporting(scores);
            reporting.Rank();

            var model = new ReportingTwoPerformanceViewModel(id, reporting);
            return View(model);
        }
        public ActionResult SinglePerformance(string id)
        {
            var performances =
                RavenSession
                    .LoadStartingWith<PerformanceScore>(id + "/scores/")
                    .Where(x => x.IsFirstPerformance);

            var info =
                RavenSession
                    .Load<CompetitionInfo>(id);

            var generator = new TeamScoreGenerator();
            var scores = generator.From(performances, info);
            var reporting = new TeamScoreReporting(scores);
            reporting.Rank();

            var model = new ReportingSinglePerformanceViewModel(id, reporting);
            return View(model);
        }
Exemplo n.º 4
0
 public void WhenPerformancesAreGrouped()
 {
     var generator = new TeamScoreGenerator();
     var scores = generator.From(_performances, null);
     _reporting = new TeamScoreReporting(scores);
 }