Пример #1
0
    void Register()
    {
        mWaiting.SetActive(true);

        BackendlessUser user = new BackendlessUser();

        user.Email    = mEmail;
        user.Password = mPassword;
        user.AddProperty("name", mName);

        AsyncCallback <BackendlessUser> callback = new AsyncCallback <BackendlessUser>(
            savedUser =>
        {
            mResultMessage     = "Success\n\nThank you for registering!\nYou can use your email to login.";
            mIsRegisterFinish  = true;
            mIsRegisterSuccess = true;
        },
            fault =>
        {
            mResultMessage     = "Error\n\nCode = " + fault.FaultCode + "\nMessage = " + fault.Message;
            mIsRegisterFinish  = true;
            mIsRegisterSuccess = false;
        });

        Backendless.UserService.Register(user, callback);
    }
Пример #2
0
        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            string name = NameField.Text;

            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("Name cannot be empty");
                return;
            }

            string password = PasswordField.Password;

            if (string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Password cannot be empty");
                return;
            }

            string verifyPassword = verifyPasswordField.Password;

            if (!verifyPassword.Equals(password))
            {
                MessageBox.Show("Passwords does not match");
                return;
            }

            string email = EmailField.Text;

            if (string.IsNullOrEmpty(email))
            {
                MessageBox.Show("Email cannot be empty");
                return;
            }

            DateTime?dateOfBirth = DateOfBirthField.Value;

            if (dateOfBirth == null)
            {
                MessageBox.Show("Date of birth cannot be empty");
                return;
            }

            Gender gender = MaleRadioButton.IsChecked != null && (bool)MaleRadioButton.IsChecked
                        ? Gender.MALE
                        : Gender.FEMALE;

            var user = new BackendlessUser();

            user.Password = password;
            user.AddProperty(EMAIL_KEY, email);
            user.AddProperty(NAME_KEY, name);
            user.AddProperty(GENDER_KEY, gender);
            user.AddProperty(DATE_OF_BIRTH_KEY, dateOfBirth);
            user.AddProperty(LOGIN_KEY, email);

            Backendless.UserService.Register(user,
                                             new AsyncCallback <BackendlessUser>(
                                                 response =>
                                                 Dispatcher.BeginInvoke(
                                                     () =>
                                                     NavigationService.Navigate(new Uri("/RegisteredPage.xaml",
                                                                                        UriKind.Relative))),
                                                 fault => Dispatcher.BeginInvoke(() => MessageBox.Show(fault.Message))));
        }