예제 #1
0
		public async Task Submit()
		{
			this.IsBusy = true;

			var hasError = false;
			try
			{
				this.User = await this.User.SaveAsync() as IUser;

				var identity = await this.userIdentityObjectFactory.FetchAsync(this.User.ProfileID);

				var principal = new CslaPrincipalCore(identity);
				Csla.ApplicationContext.User = principal;
			}
			catch (DataPortalException ex)
			{
				System.Diagnostics.Debug.WriteLine(ex);
				hasError = true;
			}
			this.IsBusy = false;

			if (!hasError)
			{
				// Always navigate to the Polls page first.
				this.Navigation.NavigateToViewModel<PollsPageViewModel>();

				// If there is a PollId, the user is coming in from a URI link.
				// Navigate to the View Poll page, leaving the Polls page in the back
				// stack so the user can back up to it.
				if (this.NavigationCriteria.PollId.HasValue)
				{
					var criteria = new ViewPollPageNavigationCriteria
					{
						PollId = this.NavigationCriteria.PollId.Value
					};

					this.Navigation.NavigateToViewModel<ViewPollPageViewModel>(criteria);
				}
			}
			else
			{
#if WINDOWS_PHONE
				this.messageBox.Show("There was an error saving your profile. Please try again.", "Error");
#else
				await this.messageBox.ShowAsync("There was an error saving your profile. Please try again.", "Error");
#endif // WINDOWS_PHONE
			}
		}
예제 #2
0
		private async Task LoadIdentityAndGo(string profileId)
		{
			IUserIdentity identity = null;
			IsBusy = true;
            try
            {
                //identity = (this.objectFactory as IObjectFactory<IUserIdentity>).Fetch(profileId);
                identity = await this.ObjectFactory.FetchAsync(profileId);

                var principal = new CslaPrincipalCore(identity);
                Csla.ApplicationContext.User = principal;
            }
            catch (DataPortalException ex)
            {
                Console.WriteLine(ex.Message);
                identity = null;
                MessageBox.Show(this, ex.Message);
            }

			IsBusy = false;
			if (identity == null)
			{
				this.MessageBox.Show(this, "There was an error retrieving your profile.", "Error");
			}

            else if (identity.IsAuthenticated)
            {
                // 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.Navigation.NavigateToViewModel<PollsPageViewModel>();
                    //this.Navigation.NavigateToViewModel<ViewPollPageViewModel>(criteria);
                }

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

                    //this.Navigation.NavigateToViewModel<PollsPageViewModel>();
                    //this.Navigation.NavigateToViewModel<ViewPollPageViewModel>(criteria);
                }
                else
                {
                    //this.Navigation.NavigateToViewModel<PollsPageViewModel>();
					var polls = new Intent (this, typeof(PollsActivity));
					StartActivity (polls);                
				}
                
            }
            else
            {
                var criteria = new RegistrationPageNavigationCriteria
                {
                    ProfileId = profileId
                };

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

				var registration = new Intent (this, typeof(RegistrationActivity));
				registration.PutExtra("NavigationCriteria_PollId", criteria.PollId ?? 0);
				registration.PutExtra ("NavigationCriteria_ProfileId", criteria.ProfileId);
				StartActivity (registration);

                //this.Navigation.NavigateToViewModel<RegistrationPageViewModel>(criteria);
                
            }

		}
예제 #3
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)
			{
				Debug.WriteLine(ex.Message);
				identity = null;
			}
			IsBusy = false;

			if (identity == null)
			{
#if WINDOWS_PHONE
				this.messageBox.Show("There was an error retrieving your profile.", "Error");
#else
				await this.messageBox.ShowAsync("There was an error retrieving your profile.", "Error");
#endif // WINDOWS_PHONE
			}
			else if (identity.IsAuthenticated)
			{
				// 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.Navigation.NavigateToViewModel<PollsPageViewModel>();
					this.Navigation.NavigateToViewModel<ViewPollPageViewModel>(criteria);
				}

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

                    this.Navigation.NavigateToViewModel<PollsPageViewModel>();
					this.Navigation.NavigateToViewModel<ViewPollPageViewModel>(criteria);
                }
                else
				{
					this.Navigation.NavigateToViewModel<PollsPageViewModel>();
				}
			}
			else
			{
				var criteria = new RegistrationPageNavigationCriteria
				{
					ProfileId = profileId
				};

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

				this.Navigation.NavigateToViewModel<RegistrationPageViewModel>(criteria);
			}
		}
예제 #4
0
		public async Task Submit()
		{

			this.IsBusy = true;

            var hasError = false;
		    DateTime birthDate;
            hasError = !DateTime.TryParse(FindViewById<Button>(Resource.Id.registration_dob).Text, out birthDate);

		    if (!hasError)
		    {
		        this.User.BirthDate = birthDate;
		        try
		        {
		            Bindings.UpdateSourceForLastView();

		            this.User = await this.User.SaveAsync() as IUser;

		            InitializeBindings(this.User);

		            var identity = await this.UserIdentityObjectFactory.FetchAsync(this.User.ProfileID);

		            var principal = new CslaPrincipalCore(identity);
		            Csla.ApplicationContext.User = principal;
		        }
		        catch (DataPortalException ex)
		        {
		            System.Diagnostics.Debug.WriteLine(ex);
		            hasError = true;
		        }
		    }
		    this.IsBusy = false;

			if (!hasError)
			{

				// Always navigate to Polls page first
				var polls = new Intent (this, typeof(PollsActivity));
				StartActivity (polls);

				// If there is a PollId, the user is coming in from a URI link.
				// Navigate to the View Poll page, leaving the Polls page in the back
				// stack so the user can back up to it.
				if (this.NavigationCriteria.PollId.HasValue)
				{
					var criteria = new ViewPollPageNavigationCriteria
					{
						PollId = this.NavigationCriteria.PollId.Value
					};

					var registration = new Intent (this, typeof(ViewPollFragment));
					registration.PutExtra("PollId", criteria.PollId);
					StartActivity (registration);

					//this.Navigation.NavigateToViewModel<ViewPollPageViewModel>(criteria);
				}

			}
			else
			{
				this.MessageBox.Show(this, "There was an error saving your profile. Please try again.", "Error");
			}

		}