Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            contest = ServiceFactory.ContestService.Get(GetContestId());
            var currentUserId = HttpContext.Current.User.Identity.GetUserId();

            judge = contest.Judges.FirstOrDefault(j => j.UserId == currentUserId);
        }
Пример #2
0
 private static void EnsureContestIsInProgress(TalentShow.Contest contest)
 {
     if (contest.Status != "In Progress")
     {
         throw new ApplicationException("The contest is not in progress. The contest must be in progress to alter a score card.");
     }
 }
Пример #3
0
        public IEnumerable <ReportContestant> GetReportContestants(TalentShow.Contest contest)
        {
            var reportContestants = new List <ReportContestant>();

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

            return(reportContestants.OrderByDescending(c => c.FinalScore));
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RedirectUtil.RedirectUnauthenticatedUserToLoginPage();

            BreadCrumbUtil.DataBind(Page, new List <BreadCrumb>()
            {
                new BreadCrumb(NavUtil.GetHomePageUrl(), "Home"),
                new BreadCrumb(NavUtil.GetShowsPageUrl(), "Shows"),
                new BreadCrumb(NavUtil.GetShowPageUrl(GetShowId()), "Show"),
                new BreadCrumb(NavUtil.GetContestPageUrl(GetShowId(), GetContestId()), "Contest"),
                new BreadCrumb(NavUtil.GetContestantPageUrl(GetShowId(), GetContestId(), GetContestantId()), "Contestant", IsActive: true),
            });

            var contestantId = GetContestantId();

            this.contestant = ServiceFactory.ContestantService.Get(contestantId);
            this.contest    = ServiceFactory.ContestService.Get(GetContestId());
            this.scoreCards = ServiceFactory.ScoreCardService.GetContestantScoreCards(contestantId);
            var performers = ServiceFactory.PerformerService.GetContestantPerformers(contestantId);

            labelPageTitle.Text       = GetContestantHeadingText(performers);
            labelPageDescription.Text = GetContestantDescriptionText(contestant);

            if (!IsUserAnAdmin())
            {
                return;
            }

            var performerItems = new List <HyperlinkListPanelItem>();

            foreach (var performer in performers)
            {
                var url     = NavUtil.GetUpdatePerformerPageUrl(GetShowId(), GetContestId(), GetContestantId(), performer.Id);
                var heading = GetPerformerHeadingText(performer);
                var text    = GetPerformerDescriptionText(performer);

                performerItems.Add(new HyperlinkListPanelItem(url, heading, text));
            }

            HyperlinkListPanelRenderer.Render(performersList, new HyperlinkListPanelConfig("Performers", performerItems, ButtonAddPerformerClick));
        }
Пример #5
0
        private ReportContestant GetReportContestants(TalentShow.Contest contest, 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 ReportContestant
                 (
                     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),
                     Organization: organization,
                     ParentOrganization: parentOrganization
                 ));
        }
Пример #6
0
 protected string GetContestantURL(int contestantId, TalentShow.Contest contest)
 {
     return(NavUtil.GetContestantPageUrl(GetShowId(), contest.Id, contestantId));
 }
Пример #7
0
 protected IEnumerable <ReportContestant> GetReportContestants(TalentShow.Contest contest)
 {
     return(new ReportContestantsProvider().GetReportContestants(contest));
 }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RedirectUtil.RedirectUnauthenticatedUserToLoginPage();

            BreadCrumbUtil.DataBind(Page, new List <BreadCrumb>()
            {
                new BreadCrumb(NavUtil.GetHomePageUrl(), "Home"),
                new BreadCrumb(NavUtil.GetShowsPageUrl(), "Shows"),
                new BreadCrumb(NavUtil.GetShowPageUrl(GetShowId()), "Show"),
                new BreadCrumb(NavUtil.GetContestPageUrl(GetShowId(), GetContestId()), "Contest", IsActive: true),
            });

            var showId = GetShowId();
            var show   = ServiceFactory.ShowService.Get(showId);

            var contestId = GetContestId();

            this.contest = ServiceFactory.ContestService.Get(contestId);

            labelPageTitle.Text       = contest.Name + " (" + contest.Status + ")";
            labelPageDescription.Text = contest.Description;

            if (IsAllowedToViewContestantsList())
            {
                var contestantItems = new List <HyperlinkListPanelItem>();

                foreach (var contestant in contest.Contestants)
                {
                    var url     = NavUtil.GetContestantPageUrl(showId, contestId, contestant.Id);
                    var heading = GetContestantHeadingText(contestant);
                    var text    = GetContestantDescriptionText(contestant);

                    contestantItems.Add(new HyperlinkListPanelItem(url, heading, text));
                }

                HyperlinkListPanelRenderer.Render(contestantsList, new HyperlinkListPanelConfig("Contestants", contestantItems, ButtonAddContestantClick));
            }

            if (!IsUserAnAdmin())
            {
                return;
            }

            var judgeItems = new List <HyperlinkListPanelItem>();

            foreach (var judge in contest.Judges)
            {
                var url     = NavUtil.GetUpdateJudgePageUrl(showId, contestId, judge.Id);
                var heading = GetJudgeHeadingText(judge);
                var text    = GetJudgeDescriptionText(judge);

                judgeItems.Add(new HyperlinkListPanelItem(url, heading, text));
            }

            HyperlinkListPanelRenderer.Render(judgesList, new HyperlinkListPanelConfig("Judges", judgeItems, ButtonAddJudgeClick));

            var scoreCriterionItems = new List <HyperlinkListPanelItem>();

            foreach (var scoreCriterion in contest.ScoreCriteria)
            {
                var url     = NavUtil.GetUpdateScoreCriterionPageUrl(showId, contestId, scoreCriterion.Id);
                var heading = GetScoreCriterionHeadingText(scoreCriterion);
                var text    = GetScoreCriterionDescriptionText(scoreCriterion);

                scoreCriterionItems.Add(new HyperlinkListPanelItem(url, heading, text));
            }

            HyperlinkListPanelRenderer.Render(scoreCriteriaList, new HyperlinkListPanelConfig("Score Criteria", scoreCriterionItems, ButtonAddScoreCriterionClick));
        }