Пример #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));
            }
        }
        //          CONSTRUCTOR
        public LeagueViewModel(TournamentModel selectedTournament)
        {
            CurrentTournament = selectedTournament;

            _tournamentName = CurrentTournament.TournamentName;
            _roundList      = new BindableCollection <RoundModel>(SqlDataHandler.GetRoundsByTournament(CurrentTournament.Id));

            EnterAutomaticResults();

            _selectedRound      = _roundList[0];
            _gameList           = new BindableCollection <GameModel>(SelectedRound.Games);
            _leagueParticipants = new BindableCollection <LeagueParticipantModel>(SqlDataHandler.GetLeagueParticipantsForDisplay(CurrentTournament.Id));

            ScoreDifferenceAndPositionNumber();
        }
        public void RefreshTable()
        {
            LeagueParticipants = new BindableCollection <LeagueParticipantModel>(SqlDataHandler.GetLeagueParticipantsForDisplay(CurrentTournament.Id));

            ScoreDifferenceAndPositionNumber();
        }