/// <summary> /// Instantiates a new HeadJudgeViewModel by loading necessary properties from Tournament.. /// </summary> public HeadJudgeViewModel(Tournament tourney, NordicArenaDomainModels.Models.Judge judge, ICollection <NordicArenaDomainModels.Models.Judge> judges) { Tournament = tourney; Criteria = tourney.JudgingCriteria.OrderBy(p => p.Id).ToList(); Judges = judges; Judge = judge; Contestants = ContestantRunViewModel.CreateListOfCurrentConestants(tourney, judge.Id); //CanJudge = Contestants.Count > 0 && Contestants[0].Scores.All(p => p.Score != null); JudgeStatus = JudgeHasScoredTuple.GetJudgeStatusListForCurrentHeat(tourney); JudgeViewModels = GetJudgeViewModels(); AverageCriteriaScore = new List <decimal?>(); foreach (var j in JudgeStatus) { if (!j.HasJudged) { CanJudge = false; } } if (CanJudge) { SetAverageScores(); } }
/// <summary> /// Retruns list of contestants currently running in the current heat, with stored scores (if any) for the specified judge /// </summary>s /// <param name="tourney">Tournament ID</param> /// <param name="judgeId">Judge ID</param> public static List <ContestantRunViewModel> CreateListOfCurrentConestants(Tournament tourney, long judgeId) { var round = tourney.GetCurrentRound(); if (round == null) { throw new ArgumentException("No active round"); } var currentHeat = tourney.GetRoundCounter().GetHeatNo(); var contestants = round.GetContestantsInHeat(currentHeat).ToList(); var modelList = new List <ContestantRunViewModel>(); foreach (long contestantId in contestants.Select(p => p.Id)) { var model = new ContestantRunViewModel(tourney, round, judgeId, contestantId); modelList.Add(model); } return(modelList); }
/// <summary> /// Instantiates a new JudgeViewModel by loading necessary properties from Tournament.. /// </summary> public JudgeViewModel(Tournament tourney, NordicArenaDomainModels.Models.Judge judge) { Tournament = tourney; Criteria = tourney.JudgingCriteria.OrderBy(p => p.Id).ToList(); Judge = judge; Contestants = ContestantRunViewModel.CreateListOfCurrentConestants(tourney, judge.Id); ClosestContestants = new ClosestContestantsViewModel(tourney, tourney.GetCurrentRound().RoundNo); if (Judge.IsHeadJudge) { AverageCriteriaScore = new List <decimal?>(); AverageTotalScore = new List <decimal?>(); RemoveHeadJudgeFromJudgeList(Tournament.Judges, Judge.Id); Judges = Tournament.Judges; JudgeStatus = JudgeHasScoredTuple.GetJudgeStatusListForCurrentHeat(tourney); JudgeViewModels = GetJudgeViewModels(); CanJudge = true; foreach (var j in JudgeStatus) { if (!j.HasJudged) { CanJudge = false; } } HasHeadJudgeJudged = SetHasHeadJudgeJudged(); if (!HasHeadJudgeJudged && JudgeStatus.Count > 0) { SetAverageScores(); } } else { CanJudge = Contestants.Count > 0 && Contestants[0].Scores.All(p => p.Score == null); } }