Example #1
0
        protected IEnumerable <ReportContestant> GetReportContestants(TalentShow.Contest contest)
        {
            var numberOfContestants = 4;

            var topFour = new ReportContestantsProvider().GetReportContestants(contest).Take(numberOfContestants).ToList();

            while (topFour.Count() != numberOfContestants)
            {
                topFour.Add(null);
            }

            return(topFour);
        }
Example #2
0
        protected void btnUpdateContest_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                //TODO
                return;
            }

            var contestName = contestForm.GetContestNameTextBox().Text.Trim();
            var description = contestForm.GetDescriptionTextBox().Text.Trim();
            var timeKeeper  = contestForm.GetTimeKeepersDropDownList().SelectedValue.Trim();
            var maxDuration = new TimeSpan(0, Convert.ToInt32(contestForm.GetMaxDurationTextBox().Text.Trim()), 0);
            var status      = contestForm.GetStatusDropDownList().SelectedValue.Trim();
            var contest     = new TalentShow.Contest(GetContestId(), contestName, description, timeKeeper, maxDuration, status);

            ServiceFactory.ContestService.Update(contest);
            GoToContestPage();
        }
Example #3
0
        public IEnumerable <JudgeSheetReportContestantScoreCard> GetReportContestants(TalentShow.Contest contest)
        {
            var reportContestants = new List <JudgeSheetReportContestantScoreCard>();

            foreach (var contestant in contest.Contestants)
            {
                reportContestants.Add(GetReportContestant(contest, contestant));
            }

            return(reportContestants.OrderByDescending(c => c.FinalScore));
        }
Example #4
0
        private JudgeSheetReportContestantScoreCard GetReportContestant(TalentShow.Contest contest, TalentShow.Contestant contestant)
        {
            var    scoreCards  = ServiceFactory.ScoreCardService.GetContestantScoreCards(contestant.Id);
            var    totalScore  = scoreCards.Sum(s => s.TotalScore) + contestant.TieBreakerPoints;
            var    finalScore  = ServiceFactory.ScoreCardService.GetContestantTotalScore(contestant, contest.MaxDuration);
            double lowestScore = 0;

            var lowestScoreCard = scoreCards.OrderBy(s => s.TotalScore).FirstOrDefault();

            if (lowestScoreCard != null)
            {
                lowestScore = lowestScoreCard.TotalScore;
            }

            double highestScore = 0;

            if (scoreCards != null && scoreCards.Count == 5)
            {
                var highestScoreCard = scoreCards.OrderByDescending(s => s.TotalScore).FirstOrDefault();

                if (highestScoreCard != null)
                {
                    highestScore = highestScoreCard.TotalScore;
                }
            }

            var penaltyPoints = ((totalScore - lowestScore) - highestScore) - finalScore;

            string organization       = "";
            string parentOrganization = "";

            var performers = ServiceFactory.PerformerService.GetContestantPerformers(contestant.Id);

            if (performers != null && performers.Any())
            {
                var firstPerformer = performers.First();

                if (firstPerformer.Affiliation != null)
                {
                    organization = firstPerformer.Affiliation.Name;

                    if (firstPerformer.Affiliation.Parent != null)
                    {
                        parentOrganization = firstPerformer.Affiliation.Parent.Name;
                    }
                }
            }

            return
                (new JudgeSheetReportContestantScoreCard
                 (
                     ContestantId: contestant.Id,
                     Name: ContestantNameUtil.GetContestantName(contestant.Id),
                     PerformanceDescription: contestant.Performance.Description,
                     PerformanceDuration: contestant.Performance.Duration,
                     TotalScore: totalScore,
                     PenaltyPoints: penaltyPoints,
                     FinalScore: finalScore,
                     LowestScore: lowestScore,
                     SumOfTopScores: totalScore - lowestScore,
                     NumberOfScoreCards: scoreCards.Count,
                     NumberOfJudges: contest.Judges.Count,
                     Scores: ScoresUtil.GetScores(scoreCards),
                     ScoreCards: scoreCards,
                     Organization: organization,
                     ParentOrganization: parentOrganization
                 ));
        }
        public static void Import(TalentShow.Show show, Stream fileStream)
        {
            var context           = HttpContext.Current;
            var util              = new BrushfireAttendeeDocumentUtil(fileStream);
            var brushFireContests = util.GetContests();
            var divisions         = ServiceFactory.DivisionService.GetAll();

            if (divisions.FirstOrDefault(d => d.Name.ToUpper().Trim() == "ALPHA") == null ||
                divisions.FirstOrDefault(d => d.Name.ToUpper().Trim() == "GAMMA") == null ||
                divisions.FirstOrDefault(d => d.Name.ToUpper().Trim() == "OMEGA") == null)
            {
                throw new ApplicationException("To Import Data from Excel you must have Divisions: Alpha, Gamma, and Omega.");
            }

            var defaultOrganization = ServiceFactory.OrganizationService.GetAll().FirstOrDefault(o => o.Name.ToUpper().Trim() == "UNKNOWN");

            if (defaultOrganization == null)
            {
                throw new ApplicationException("To Import Data from Excel you must have an Organization named \"UNKNOWN\".");
            }

            //var users = new AccountUtil(context).GetAllUsers().Take(4);
            //var judges = new List<TalentShow.Judge>();

            //foreach (var user in users)
            //judges.Add(new TalentShow.Judge(id: 0, userId: user.Id));

            foreach (var brushFireContest in brushFireContests)
            {
                if (brushFireContest.Contestants.Count() == 0)
                {
                    continue;
                }

                //Add Contest
                var contest = new TalentShow.Contest(
                    id: 0,
                    name: ConvertToTitleCase(brushFireContest.Name),
                    description: ConvertToTitleCase(brushFireContest.Division),
                    timeKeeperId: context.User.Identity.GetUserId(),
                    maxDuration: new TimeSpan(0, 5, 0),
                    status: "Pending"
                    );

                ServiceFactory.ContestService.AddShowContest(show.Id, contest);

                //Add Judges to Contest
                //foreach (var judge in judges)
                //ServiceFactory.JudgeService.AddContestJudge(contest.Id, judge);

                //Add Score Criteria to Contest
                var scoreCriteria = new List <TalentShow.ScoreCriterion>();

                if (brushFireContest.ScoreCriteria.Any())
                {
                    foreach (var criterion in brushFireContest.ScoreCriteria)
                    {
                        scoreCriteria.Add(new TalentShow.ScoreCriterion(
                                              id: 0,
                                              criterionDescription: ConvertToTitleCase(criterion.Description),
                                              scoreRange: new TalentShow.ScoreRange(criterion.Min, criterion.Max)
                                              )
                                          );
                    }
                }
                else
                {
                    scoreCriteria.Add(new TalentShow.ScoreCriterion(id: 0, criterionDescription: "Selection & Communication", scoreRange: new TalentShow.ScoreRange(0, 10)));
                    scoreCriteria.Add(new TalentShow.ScoreCriterion(id: 0, criterionDescription: "Technique, Intonation", scoreRange: new TalentShow.ScoreRange(0, 10)));
                    scoreCriteria.Add(new TalentShow.ScoreCriterion(id: 0, criterionDescription: "Overall Presentation", scoreRange: new TalentShow.ScoreRange(0, 10)));
                    scoreCriteria.Add(new TalentShow.ScoreCriterion(id: 0, criterionDescription: "Diction", scoreRange: new TalentShow.ScoreRange(0, 10)));
                    scoreCriteria.Add(new TalentShow.ScoreCriterion(id: 0, criterionDescription: "Musical Effect Communication", scoreRange: new TalentShow.ScoreRange(0, 10)));
                }

                foreach (var scoreCriterion in scoreCriteria)
                {
                    ServiceFactory.ScoreCriterionService.AddContestScoreCriterion(contest.Id, scoreCriterion);
                }

                //Add Contestants to Contest
                foreach (var brushFireContestant in brushFireContest.Contestants)
                {
                    var contestant = new TalentShow.Contestant(
                        id: 0,
                        performance: new TalentShow.Performance(
                            id: 0,
                            description: ConvertToTitleCase(brushFireContestant.PerformanceDescription),
                            duration: new TimeSpan(0)
                            ),
                        ruleViolationPenalty: 0,
                        tieBreakerPoints: 0
                        );

                    ServiceFactory.ContestantService.AddContestContestant(contest.Id, contestant);

                    //Add Performers to Contestant
                    foreach (var brushFirePerformer in brushFireContestant.Performers)
                    {
                        int divisionId = divisions.First(d => d.Name.ToUpper().Trim() == brushFireContest.Division.ToUpper().Trim()).Id;

                        ServiceFactory.PerformerService.AddContestantPerformer(contestant.Id, new TalentShow.Performer(
                                                                                   id: 0,
                                                                                   division: ServiceFactory.DivisionService.Get(divisionId),
                                                                                   name: new TalentShow.PersonName(ConvertToTitleCase(brushFirePerformer.FirstName), ConvertToTitleCase(brushFirePerformer.LastName)),
                                                                                   affiliation: GetOrganization(defaultOrganization, brushFirePerformer.Organization, brushFirePerformer.ParentOrganization)
                                                                                   )
                                                                               );
                    }

                    //Add Score Cards to Contestant

                    /*
                     * var scorableCriteria = new List<TalentShow.ScorableCriterion>();
                     *
                     * foreach (var scoreCriterion in scoreCriteria)
                     *  scorableCriteria.Add(new TalentShow.ScorableCriterion(id: 0, scoreCriterion: scoreCriterion));
                     *
                     * foreach (var judge in judges)
                     * {
                     *  ServiceFactory.ScoreCardService.Add(
                     *      new TalentShow.ScoreCard(
                     *          id: 0,
                     *          contestant: contestant,
                     *          judge: judge,
                     *          scorableCriteria: scorableCriteria
                     *      )
                     *  );
                     * }
                     */
                }
            }
        }
Example #6
0
 protected string GetContestantURL(int contestantId, TalentShow.Contest contest)
 {
     return(NavUtil.GetContestantPageUrl(GetShowId(), contest.Id, contestantId));
 }
Example #7
0
        protected IEnumerable <JudgeSheetReportContestantScoreCard> GetReportContestants(TalentShow.Contest contest)
        {
            var provider = new JudgeSheetReportContestantScoreCardProvider();

            int contestantId = Convert.ToInt32(Request.QueryString["contestantId"]);

            if (contestantId > 0)
            {
                return(provider.GetReportContestants(contest, contestantId));
            }
            else
            {
                return(provider.GetReportContestants(contest));
            }
        }