Beispiel #1
0
		protected override async void OnCreate (Bundle bundle)
		{
			MyVoteActivity.setLoadingMessage ("Loading User Registration interface...");
			base.OnCreate (bundle);

			this.NavigationCriteria = new RegistrationPageNavigationCriteria ();
			this.NavigationCriteria.PollId = Intent.GetIntExtra ("NavigationCriteria_PollId", 0);
			this.NavigationCriteria.ProfileId = Intent.GetStringExtra ("NavigationCriteria_ProfileId");

			this.Bindings = new BindingManager (this);

			SetContentView(Resource.Layout.registration);

			_SubmitButton = FindViewById<Button>(Resource.Id.SubmitRegistrationButton);
			_SubmitButton.Click += SubmitRegistrationClicked;
            _SubmitButton.Enabled = false;


            FindViewById(Resource.Id.registration_sex).Click += HandleClick;
            _date = FindViewById<Button>(Resource.Id.registration_dob);
            _date.Click += (sender, e) =>
            {
                ShowDialog(0);
            };


			// OnInitialize isn't async, so we have to go old school.
			await this.CreateUserAsync();

            _date.Text = !this.User.BirthDate.HasValue ? "Enter birthdate" : this.User.BirthDate.Value.ToString ("d");  

			this.InitializeBindings (this.User);

		}
Beispiel #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);
                
            }

		}
Beispiel #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);
			}
		}