private static List <MatchUpModel> CreateFirstRound(int byes, List <TeamModel> teams) { List <MatchUpModel> output = new List <MatchUpModel>(); MatchUpModel curr = new MatchUpModel(); foreach (TeamModel team in teams) { curr.Entries.Add(new MatchUpEntryModel { TeamCompeting = team }); if (byes > 0 || curr.Entries.Count > 1) { curr.MatchUpRound = 1; output.Add(curr); curr = new MatchUpModel(); if (byes >= 0) { byes -= 1; } } } return(output); }
private static void CreateOtherRounds(TournamentModel model, int Rounds) { int round = 2; List <MatchUpModel> previousRound = model.Rounds[0]; List <MatchUpModel> currRound = new List <MatchUpModel>(); MatchUpModel currMatchUp = new MatchUpModel(); while (round <= Rounds) { foreach (MatchUpModel match in previousRound) { currMatchUp.Entries.Add(new MatchUpEntryModel { ParentMatchUp = match }); if (currMatchUp.Entries.Count > 1) { currMatchUp.MatchUpRound = round; currRound.Add(currMatchUp); currMatchUp = new MatchUpModel(); } } model.Rounds.Add(currRound); previousRound = currRound; currRound = new List <MatchUpModel>(); round += 1; } }