ActivEarth.Server.Service.Competition.ContestManager.GetTeamsToDisplay C# (CSharp) Method

GetTeamsToDisplay() public static method

Finds the list of teams that should be displayed to the user as part of the contest standings report. For the user's current bracket, the user's team will be shown. For brackets better than the user's current standing, the lowest team in the bracket is shown (the team that the user needs to pass to enter that bracket). For brackets worse than the user's current standing, the top team in the bracket is shown (the team that the user needs to stay ahead of to avoid falling into that bracket).
public static GetTeamsToDisplay ( ContestTeam userTeam, Contest contest ) : List
userTeam ActivEarth.Objects.Competition.Contests.ContestTeam Team that the current user is on.
contest ActivEarth.Objects.Competition.Contests.Contest Contest to be analyzed.
return List
        public static List<ContestTeam> GetTeamsToDisplay(ContestTeam userTeam, Contest contest)
        {
            int userBracket;
            List<ContestTeam> toDisplay = new List<ContestTeam>();

            if (userTeam == null)
            {
                userBracket = (int)ContestBracket.Diamond + 1;
            }
            else
            {
                userBracket = userTeam.Bracket;
            }

            List<ContestTeam> diamond = contest.Teams.Where(t => t.Bracket == (int)ContestBracket.Diamond).ToList();
            List<ContestTeam> platinum = contest.Teams.Where(t => t.Bracket == (int)ContestBracket.Platinum).ToList();
            List<ContestTeam> gold = contest.Teams.Where(t => t.Bracket == (int)ContestBracket.Gold).ToList();
            List<ContestTeam> silver = contest.Teams.Where(t => t.Bracket == (int)ContestBracket.Silver).ToList();
            List<ContestTeam> bronze = contest.Teams.Where(t => t.Bracket == (int)ContestBracket.Bronze).ToList();

            if ((int)ContestBracket.Diamond > userBracket)
                { toDisplay.Add(diamond.LastOrDefault()); }
            else if ((int)ContestBracket.Diamond == userBracket)
                { toDisplay.Add(userTeam); }
            else
                { toDisplay.Add(diamond.FirstOrDefault()); }

            if ((int)ContestBracket.Platinum > userBracket)
                { toDisplay.Add(platinum.LastOrDefault()); }
            else if ((int)ContestBracket.Platinum == userBracket)
                { toDisplay.Add(userTeam); }
            else
                { toDisplay.Add(platinum.FirstOrDefault()); }

            if ((int)ContestBracket.Gold > userBracket)
                { toDisplay.Add(gold.LastOrDefault()); }
            else if ((int)ContestBracket.Gold == userBracket)
                { toDisplay.Add(userTeam); }
            else
                { toDisplay.Add(gold.FirstOrDefault()); }

            if ((int)ContestBracket.Silver > userBracket)
                { toDisplay.Add(silver.LastOrDefault()); }
            else if ((int)ContestBracket.Silver == userBracket)
                { toDisplay.Add(userTeam); }
            else
                { toDisplay.Add(silver.FirstOrDefault()); }

            if ((int)ContestBracket.Bronze > userBracket)
                { toDisplay.Add(bronze.LastOrDefault()); }
            else if ((int)ContestBracket.Bronze == userBracket)
                { toDisplay.Add(userTeam); }
            else
                { toDisplay.Add(bronze.FirstOrDefault()); }

            return toDisplay;
        }