Пример #1
0
        public override void NotifyPropertiesChanged([CallerMemberName] string caller = "")
        {
            Debug.WriteLine($"Notify called for League - {League?.Name} by {caller}");
            base.NotifyPropertiesChanged();

            App.Instance.CurrentAthlete.LocalRefresh();
            League.LocalRefresh();

            CurrentMembership?.LocalRefresh();
            SetPropertyChanged("CurrentMembership");

            if (CurrentMembership?.OngoingChallenges == null)
            {
                OngoingChallengeViewModels = new ObservableCollection <ChallengeDetailsViewModel>();
            }
            else if (CurrentMembership?.OngoingChallenges != null)
            {
                SetOngoingChallenges();
            }
            else
            {
                SetPropertyChanged("OngoingChallengeViewModels");
                OngoingChallengeViewModels.ForEach(vm => vm.NotifyPropertiesChanged());
            }

            MembershipViewModel?.NotifyPropertiesChanged();
        }
Пример #2
0
        void SetOngoingChallenges()
        {
            if (OngoingChallengeViewModels == null)
            {
                OngoingChallengeViewModels = new ObservableCollection <ChallengeDetailsViewModel>();
            }

            OngoingChallengeViewModels.Clear();

            if (CurrentMembership != null)
            {
                foreach (var challenge in CurrentMembership.OngoingChallenges)
                {
                    OngoingChallengeViewModels.Add(new ChallengeDetailsViewModel {
                        Challenge = challenge
                    });
                }
            }
        }
Пример #3
0
        public void SetOngoingChallenges()
        {
            if (OngoingChallengeViewModels == null)
            {
                OngoingChallengeViewModels = new ObservableCollection <ChallengeDetailsViewModel>();
            }

            if (CurrentMembership?.OngoingChallenges != null)
            {
                foreach (var challenge in CurrentMembership.OngoingChallenges)
                {
                    if (OngoingChallengeViewModels.Any(vm => vm.Challenge.Id == challenge.Id))
                    {
                        continue;
                    }

                    //Was added
                    OngoingChallengeViewModels.Add(new ChallengeDetailsViewModel {
                        Challenge = challenge
                    });
                }

                foreach (var vm in OngoingChallengeViewModels.ToList())
                {
                    if (CurrentMembership.OngoingChallenges.Any(c => c.Id == vm.Challenge.Id))
                    {
                        vm.NotifyPropertiesChanged();
                        continue;
                    }

                    //Was removed
                    OngoingChallengeViewModels.Remove(vm);
                }
            }

            SetPropertyChanged("OngoingChallengeViewModels");
        }