Example #1
0
        private void WireUpTournamentOrder()
        {
            if (finishedTournament.IsLeague)
            {
                List <LeagueParticipantModel> leagueParticipants = SqlDataHandler.GetLeagueParticipantsForDisplay(finishedTournament.Id);
                _champion = new TeamModel(leagueParticipants.First().TeamName);
                _runnerUp = new TeamModel(leagueParticipants[1].TeamName);
                _thirdPlaced.Add(new TeamModel(leagueParticipants[2].TeamName));
            }
            else
            {
                RoundModel       finalRound   = finishedTournament.Rounds.Last();
                List <TeamModel> roundWinners = SqlDataHandler.GetRoundWinners(finalRound.Id);

                _champion = roundWinners.First();
                _runnerUp = new TeamModel(finalRound.Games[0].Competitors.Find(team => team.CupRoundWinner == false).TeamName);



                RoundModel                  secondToLastRound = finishedTournament.Rounds[finalRound.RoundNumber - 2];
                List <GameModel>            semiFinalGames    = SqlDataHandler.GetGamesByRound(secondToLastRound);
                List <GameParticipantModel> semiFinalLosers   = new List <GameParticipantModel>();

                foreach (GameModel game in semiFinalGames)
                {
                    semiFinalLosers.Add(game.Competitors.Find(team => team.CupRoundWinner == false));
                }

                _thirdPlaced.Add(new TeamModel(semiFinalLosers[0].TeamName));
                _thirdPlaced.Add(new TeamModel(semiFinalLosers[1].TeamName));
            }
        }
        public void RoundListSelectionChanged()
        {
            if (SelectedRound.Games.Count == 0)
            {
                SelectedRound.Games = SqlDataHandler.GetGamesByRound(SelectedRound);
            }

            if (UnplayedOnly)
            {
                GameList = new BindableCollection <GameModel>(SelectedRound.Games.Where(game => game.Unplayed == true));
            }
            else
            {
                GameList = new BindableCollection <GameModel>(SelectedRound.Games);
            }

            DisplayRound();
        }