コード例 #1
0
		public void EditProfileCommand()
		{
		    this.IsBusy = true;
            this.IsEnabled = false;
            var profileId = ((IUserIdentity)Csla.ApplicationContext.User.Identity).ProfileID;
			var criteria = new RegistrationPageNavigationCriteria
			{
				ProfileId = profileId,
				ExistingUser = true
			};

			this.ShowViewModel<RegistrationPageViewModel>(criteria);
            this.IsBusy = false;
        }
コード例 #2
0
        private async Task LoadIdentityAndGo(string profileId)
        {
            IUserIdentity identity = null;

            IsBusy = true;
            try
            {
                identity = await this.objectFactory.FetchAsync(profileId);

                var principal = new CslaPrincipalCore(identity);
                Csla.ApplicationContext.User = principal;
            }
            catch (DataPortalException ex)
            {
                this.logger.Log(ex);
                identity = null;
            }

            IsBusy = false;

            if (identity == null)
            {
                await this.messageBox.ShowAsync("There was an error retrieving your profile.", "Error");
            }
            else if (identity.IsAuthenticated)
            {
#if MOBILE
                Xamarin.Insights.Identify(profileId, Xamarin.Insights.Traits.Name, identity.UserName);
                Xamarin.Forms.MessagingCenter.Subscribe <VmPageMappings>(this, string.Format(Constants.Navigation.PageNavigated, typeof(PollsPageViewModel)), (sender) =>
                {
                    Xamarin.Forms.MessagingCenter.Unsubscribe <VmPageMappings>(this, string.Format(Constants.Navigation.PageNavigated, typeof(PollsPageViewModel)));
                    //this.Close(this);
                    ChangePresentation(new ClearBackstackHint());
                });
#endif // MOBILE

                // If there is a PollId, the user is coming in from a URI.
                // Navigate to the Polls page, which adds it to the back stack.
                // Then, navigate to the View Poll page. This allows the user to be able
                // to back out of the View Poll page and land on the Polls page, rather than
                // leaving the app.
                if (this.NavigationCriteria != null && this.NavigationCriteria.PollId.HasValue)
                {
                    var criteria = new ViewPollPageNavigationCriteria
                    {
                        PollId = this.NavigationCriteria.PollId.Value
                    };

                    this.ShowViewModel <PollsPageViewModel>();
#if MOBILE
                    ChangePresentation(new ClearBackstackHint());
#endif
                    this.ShowViewModel <ViewPollPageViewModel>(criteria);
#if !MOBILE
                    this.Close(this);
#endif
                }

                else if (this.NavigationCriteria != null && !string.IsNullOrEmpty(this.NavigationCriteria.SearchQuery))
                {
                    var criteria = new PollsPageSearchNavigationCriteria
                    {
                        SearchQuery = this.NavigationCriteria.SearchQuery
                    };

                    this.ShowViewModel <PollsPageViewModel>();
#if MOBILE
                    ChangePresentation(new ClearBackstackHint());
#endif
                    this.ShowViewModel <ViewPollPageViewModel>(criteria);
#if !MOBILE
                    this.Close(this);
#endif
                }
                else
                {
                    this.ShowViewModel <PollsPageViewModel>();
#if MOBILE
                    ChangePresentation(new ClearBackstackHint());
#endif
#if !MOBILE
                    this.Close(this);
#endif
                }
            }
            else
            {
                var criteria = new RegistrationPageNavigationCriteria
                {
                    ProfileId = profileId
                };

                if (this.NavigationCriteria != null)
                {
                    criteria.PollId = this.NavigationCriteria.PollId;
                }

                this.ShowViewModel <RegistrationPageViewModel>(criteria);
            }
        }