Ejemplo n.º 1
0
        void RegisterUser()
        {
            if (State == RegisterState.None)
            {
                // make sure they entered all required fields
                if (ValidateInput( ))
                {
                    ToggleControls(false);

                    ProgressBarBlocker.Visibility = ViewStates.Visible;
                    State = RegisterState.Trying;

                    // create a new user and submit them
                    Rock.Client.Person newPerson = new Rock.Client.Person();

                    // copy all the edited fields into the person object
                    newPerson.Email = EmailText.Text;

                    // set the nickName AND firstName to NickName
                    newPerson.NickName  = NickNameText.Text;
                    newPerson.FirstName = NickNameText.Text;

                    newPerson.LastName = LastNameText.Text;

                    MobileAppApi.RegisterNewUser(UserNameText.Text, PasswordText.Text, NickNameText.Text, LastNameText.Text, EmailText.Text, CellPhoneText.Text,
                                                 delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
                    {
                        ProgressBarBlocker.Visibility = ViewStates.Gone;

                        // scroll to the top so the Result is visible
                        ScrollView.Post(new Action(delegate
                        {
                            ScrollView.ScrollTo(0, 0);
                        }));

                        if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true)
                        {
                            ProfileAnalytic.Instance.Trigger(ProfileAnalytic.Register);

                            State = RegisterState.Success;
                            ResultView.Show(RegisterStrings.RegisterStatus_Success,
                                            PrivateControlStylingConfig.Result_Symbol_Success,
                                            RegisterStrings.RegisterResult_Success,
                                            GeneralStrings.Done);
                        }
                        else
                        {
                            State = RegisterState.Fail;
                            ResultView.Show(RegisterStrings.RegisterStatus_Failed,
                                            PrivateControlStylingConfig.Result_Symbol_Failed,
                                            statusDescription,
                                            GeneralStrings.Done);
                        }

                        ResultView.SetBounds(new System.Drawing.RectangleF(0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels));
                    });
                }
            }
        }
Ejemplo n.º 2
0
        void RegisterUser()
        {
            if (State == RegisterState.None)
            {
                // make sure they entered all required fields
                if (ValidateInput( ))
                {
                    BlockerView.Show(
                        delegate
                    {
                        // force the UI to scroll back up
                        ScrollView.ContentOffset = CGPoint.Empty;
                        ScrollView.ScrollEnabled = false;

                        State = RegisterState.Trying;

                        // create a new user and submit them
                        Rock.Client.Person newPerson = new Rock.Client.Person();

                        // copy all the edited fields into the person object
                        newPerson.Email = EmailText.Field.Text;

                        // set both the nick name and first name to NickName
                        newPerson.NickName  = NickNameText.Field.Text;
                        newPerson.FirstName = NickNameText.Field.Text;

                        newPerson.LastName = LastNameText.Field.Text;

                        MobileAppApi.RegisterNewUser(UserNameText.Field.Text, PasswordText.Field.Text, NickNameText.Field.Text, LastNameText.Field.Text, EmailText.Field.Text, CellPhoneText.Field.Text,
                                                     delegate(System.Net.HttpStatusCode statusCode, string statusDescription)
                        {
                            if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true)
                            {
                                ProfileAnalytic.Instance.Trigger(ProfileAnalytic.Register);

                                State = RegisterState.Success;
                                ResultView.Show(RegisterStrings.RegisterStatus_Success,
                                                PrivateControlStylingConfig.Result_Symbol_Success,
                                                RegisterStrings.RegisterResult_Success,
                                                GeneralStrings.Done);
                            }
                            else
                            {
                                State = RegisterState.Fail;
                                ResultView.Show(RegisterStrings.RegisterStatus_Failed,
                                                PrivateControlStylingConfig.Result_Symbol_Failed,
                                                statusDescription,
                                                GeneralStrings.Done);
                            }

                            BlockerView.Hide(null);
                        });
                    });
                }
            }
        }