示例#1
0
        internal MatchViewModel GetMatchViewModel(Model.Models.Tournament tournament, Model.Models.Match match, MatchViewModel successor)
        {
            MatchViewModel matchViewModel;

            if (!_matches.TryGetValue(match.Id.Value, out matchViewModel))
            {
                matchViewModel = new MatchViewModel(tournament, match, successor);
                _matches.Add(match.Id.Value, matchViewModel);
            }
            return(matchViewModel);
        }
示例#2
0
        internal PlayAreaViewModel GetPlayAreaViewModel(Model.Models.Tournament tournament, Model.Models.PlayArea playArea)
        {
            PlayAreaViewModel playAreaViewModel;

            if (!_playAreas.TryGetValue(playArea.Id.Value, out playAreaViewModel))
            {
                playAreaViewModel = new PlayAreaViewModel(tournament, playArea);
                _playAreas.Add(playArea.Id.Value, playAreaViewModel);
            }
            return(playAreaViewModel);
        }
示例#3
0
        internal TeamViewModel GetTeamViewModel(Model.Models.Tournament tournament, Model.Models.Team team)
        {
            if (team == null)
            {
                return(null);
            }
            TeamViewModel teamViewModel;

            if (!_teams.TryGetValue(team.Id.Value, out teamViewModel))
            {
                teamViewModel = new TeamViewModel(tournament, team);
                _teams.Add(team.Id.Value, teamViewModel);
            }
            return(teamViewModel);
        }
示例#4
0
        internal TournamentViewModel GetTournamentViewModel(Model.Models.Tournament tournament)
        {
            if (tournament == null)
            {
                return(null);
            }
            TournamentViewModel tournamentViewModel;

            if (!_tournament.TryGetValue(tournament.Id.Value, out tournamentViewModel))
            {
                tournamentViewModel = new TournamentViewModel(tournament);
                _tournament.Add(tournament.Id.Value, tournamentViewModel);
            }
            return(tournamentViewModel);
        }
示例#5
0
        public MatchViewModel(Model.Models.Tournament tournament, Model.Models.Match match, MatchViewModel successor) : base(match)
        {
            if (tournament == null)
            {
                throw new NullReferenceException();
            }
            _tournament = tournament;
            Successor   = successor;

            // Register message type to get informed about changes in predeseccors
            MessengerInstance.Register <MatchFinishedMessage>(this, m =>
            {
                if (m.TournamentId == tournament.Id && m.Match == FirstPredecessor || m.Match == SecondPredecessor)
                {
                    //Update current match, since one of the previous matches is finished now
                    Model = App.RestClient.GetMatchWithHttpMessagesAsync(Model.Id.Value, _tournament.Id.Value).Result.Body;
                    UpdateValuesFromModel();
                }
            });

            // Init values from model object
            UpdateValuesFromModel();
        }
示例#6
0
        private Model.Models.Tournament CreateDesignTimeVm()
        {
            #region Dummy PlayAreas
            var playAreas = new List <Model.Models.PlayArea>();
            playAreas.Add(new Model.Models.PlayArea(1, "Area 1", "Play Area 1"));
            playAreas.Add(new Model.Models.PlayArea(1, "Area 2", "Play Area 2"));
            #endregion

            #region Dummy Teams
            var teams = new List <Model.Models.Team>();
            teams.Add(new Model.Models.Team(1, "Team 1"));
            teams.Add(new Model.Models.Team(2, "Team 2"));
            teams.Add(new Model.Models.Team(3, "Team 3"));
            teams.Add(new Model.Models.Team(4, "Team 4"));
            teams.Add(new Model.Models.Team(5, "Team 5"));
            teams.Add(new Model.Models.Team(6, "Team 6"));
            teams.Add(new Model.Models.Team(7, "Team 7"));
            teams.Add(new Model.Models.Team(8, "Team 8"));
            #endregion

            var finalMatch = new Model.Models.Match(1, new Model.Models.Team(1, "Team 1"), new Model.Models.Team(2, "Team 2"), playAreas[0], DateTime.Now, DateTime.Now.AddMinutes(60), null, null, 2, null, null, null, null);
            var tournament = new Model.Models.Tournament(1, "Ping-Pong", "nur die Harten kommen in den Garten...", DateTime.Now, 60, 8, 1, playAreas, teams, finalMatch);
            return(tournament);
        }
示例#7
0
 public TeamViewModel(Model.Models.Tournament tournament, Team team) : base(team)
 {
     _tournament = tournament;
     _name       = team.Name;
 }
示例#8
0
 public MatchViewModel(Model.Models.Tournament tournament, Model.Models.Match match) : this(tournament, match, null)
 {
 }
示例#9
0
 public PlayAreaViewModel(Model.Models.Tournament tournament, Model.Models.PlayArea playArea) : base(playArea)
 {
     _tournament  = tournament;
     _name        = playArea.Name;
     _description = playArea.Description;
 }