Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPageViewModel"/> class.
        /// </summary>
        /// <param name="apiClient">
        /// The MVP API client.
        /// </param>
        /// <param name="profileData">
        /// The application's data.
        /// </param>
        public MainPageViewModel(
            ApiClient apiClient,
            IContributionSubmissionService contributionService,
            IProfileDataContainer profileData)
        {
            this.apiClient           = apiClient;
            this.contributionService = contributionService;
            this.profileData         = profileData;

            this.RecentContributions         = new ObservableCollection <Contribution>();
            this.ContributionFlyoutViewModel = new EditableContributionFlyoutViewModel();

            this.ActivityClickedCommand =
                new RelayCommand <Contribution>(c => this.ContributionFlyoutViewModel.ShowEdit(c));

            this.SaveContributionCommand = new RelayCommand(async() => await this.SaveContributionAsync());

            this.MessengerInstance.Register <ProfileUpdatedMessage>(
                this,
                args =>
            {
                if (args != null)
                {
                    this.OnProfileUpdated(args.Profile);
                }
            });

            this.MessengerInstance.Register <RefreshDataMessage>(this, this.RefreshProfileData);
        }
Ejemplo n.º 2
0
        public ContributionsPageViewModel(ApiClient client, IContributionSubmissionService contributionService)
        {
            this.contributionService = contributionService;

            this.Contributions = new LazyLoadItemCollection <Contribution, ContributionItemLoader>(15);
            this.EditableContributionFlyoutViewModel = new EditableContributionFlyoutViewModel();

            this.ContributionClickedCommand =
                new RelayCommand <Contribution>(c => this.EditableContributionFlyoutViewModel.ShowEdit(c));

            this.AddNewContributionCommand = new RelayCommand(() => this.EditableContributionFlyoutViewModel.ShowNew());

            this.SaveContributionCommand = new RelayCommand(async() => await this.SaveContributionAsync());

            this.MessengerInstance.Register <RefreshDataMessage>(this, this.OnRefreshMessage);

            this.Contributions.CollectionChanged +=
                (sender, args) => this.IsContributionsVisible = this.Contributions.Any();
        }