public ResultReasonTuple CanBeEnded() { var result = new ResultReasonTuple(true); if (Status == TournamentStatus.Prestart) { return(new ResultReasonTuple(false, Text.RoundNotStarted)); } if (Status == TournamentStatus.Ended) { return(new ResultReasonTuple(false, Text.RoundAlreadyEnded)); } var nonScoredContestants = ContestantEntries.Where(p => p.TotalScore == null).Select(p => p.Contestant.Name); if (nonScoredContestants.Count() != 0) { result.IsTrue = false; if (nonScoredContestants.Count() > 1) { result.Reason = Text.ContestantsNotScored; } else { result.Reason = String.Format(Text.ContestantXNotScored, nonScoredContestants.First()); } } return(result); }
public RoundContestant GetRoundContestantGuarded(long roundContestantId) { var contestant = ContestantEntries.FirstOrDefault(p => p.Id == roundContestantId); if (contestant == null) { throw new ArgumentException(String.Format("Could not find contestant with ID {0} in round ID {1}", roundContestantId, Id)); } return(contestant); }
public List <Object> EraseExistingContestantsAndJudgings() { var deletedObjects = new List <Object>(); foreach (var rc in ContestantEntries) { rc.EnsureListsAreInitialized(); deletedObjects.AddRange(rc.RunJudgings.ToList()); rc.RunJudgings.Clear(); } deletedObjects.AddRange(ContestantEntries); ContestantEntries.Clear(); return(deletedObjects); }
public void AssignHeatFor(RoundContestant rc) { var contestants = ContestantEntries.ToList(); var maxHeat = contestants.Max(p => p.HeatNo); int ordinal = contestants.Max(p => p.Ordinal) + 1; var playersInHeat = contestants.Count(p => p.HeatNo == maxHeat); if (playersInHeat >= ContestantsPerHeat) { maxHeat++; } rc.HeatNo = maxHeat; rc.Ordinal = ordinal; }
public List <RoundContestant> GetContestantEntriesOrdered() { return(ContestantEntries.OrderBy(p => p.Ordinal).ToList()); }
public IOrderedEnumerable <RoundContestant> GetContestantsInHeat(int heatNo) { return(ContestantEntries.Where(p => p.HeatNo == heatNo).OrderBy(p => p.Ordinal)); }
public IOrderedEnumerable <RoundContestant> GetContestantEntriesScoreSorted() { return(ContestantEntries.OrderByDescending(p => p.TotalScore)); }