Exemplo n.º 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);
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
 private void MatchesRecursion(ObservableCollection <MatchViewModel> result, MatchViewModel match)
 {
     result.Add(match);
     match.Predecessors.ForEach(p => MatchesRecursion(result, p));
 }