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); }
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); }
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); }
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); }
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(); }
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); }
public TeamViewModel(Model.Models.Tournament tournament, Team team) : base(team) { _tournament = tournament; _name = team.Name; }
public MatchViewModel(Model.Models.Tournament tournament, Model.Models.Match match) : this(tournament, match, null) { }
public PlayAreaViewModel(Model.Models.Tournament tournament, Model.Models.PlayArea playArea) : base(playArea) { _tournament = tournament; _name = playArea.Name; _description = playArea.Description; }