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 ) ) ) );
    }
    public object createObject( IAdaptingType argument )
    {
      if( argument is NamedObject )
        argument = ( (NamedObject) argument ).TypedObject;

      if( argument is NullType )
        return null;

      Dictionary<string, object> props = (Dictionary<string, object>) argument.adapt( typeof( Dictionary<string, object> ) );
      BackendlessUser backendlessUser = new BackendlessUser();
      backendlessUser.PutProperties( props );
      return backendlessUser;
    }
Esempio n. 3
0
        public void registerUserWithProperStringValueTest()
        {

            string login = "******" + random.Next();
            BackendlessUser user = new BackendlessUser { };
            user.SetProperty("email", "*****@*****.**");
            user.SetProperty("login", login);
            user.Password = "******";
            BackendlessUser expected = new BackendlessUser();
            try
            {
                expected = Backendless.UserService.Register(user);
            }
            catch (System.Exception e)
            {
                Assert.Fail(e.Message);
            }
            Assert.IsNotNull(expected, "Server returned a null result");
            Assert.IsNotNull(expected.UserId, "Server returned a null id");
            Assert.AreEqual(login, expected.Properties["login"], "Server returned wrong user login");
            Assert.AreEqual("*****@*****.**", expected.Properties["email"], "Server returned wrong user email");
            Assert.AreEqual("111222", expected.Password, "Server returned wrong user password");
        }
Esempio n. 4
0
 public void registerUserForDisabledDynamicPropertiesTest()
 {
     AsyncCallback<BackendlessUser> callback = new AsyncCallback<BackendlessUser>(
     u =>
     {
         Assert.IsNotNull(u, "Server returned a null result");
     },
     f =>
     {
         Assert.Fail(f.Message);
     });
     string login = "******" + random.Next();
     BackendlessUser user = new BackendlessUser { };
     user.SetProperty("email", "*****@*****.**");
     user.SetProperty("login", login);
     user.SetProperty("dynamic_property", "1111");
     user.Password = "******";
     Backendless.UserService.Register(user,callback);
 }
Esempio n. 5
0
        public void registerUserForDisabledDynamicPropertiesTest()
        {
            
            try
            {
                BackendlessUser user = new BackendlessUser { };

                string login = "******" + random.Next();
                user.SetProperty("email", login + "@hotmail.com");
                user.SetProperty("login", login);
                user.SetProperty("dynamic_property", "1111");
                user.Password = "******";
                BackendlessUser expected = new BackendlessUser();
                expected = Backendless.UserService.Register(user);
                Assert.IsNotNull(expected);
                Assert.IsNotNull(expected, "Server returned a null result");
                Assert.IsNotNull(expected.UserId, "Server returned a null id");
                Assert.AreEqual(login, expected.Properties["login"], "Server returned wrong user login");
                Assert.AreEqual(login + "@hotmail.com", expected.Properties["email"], "Server returned wrong user email");
                Assert.AreEqual("111222", expected.Password, "Server returned wrong user password");
                Assert.AreEqual("1111", expected.Properties["dynamic_property"], "Server returned wrong user dynamic_property");
            }
            catch (BackendlessException e)
            {
                Assert.AreEqual("1232", e.Code);
            }

        }
Esempio n. 6
0
        public void getCurrentUserTest()
        {
            try
            {
                string login = "******" + random.Next();
                BackendlessUser user = new BackendlessUser { };
                user.SetProperty("email", login + "@hotmail.com");
                user.SetProperty("login", login);
                user.Password = "******";
                Backendless.UserService.Register(user);
                Backendless.UserService.Login(login, "111222");
                Assert.AreEqual(UserService.CurrentUser.GetProperty("login").ToString(), login);
            }
            catch(BackendlessException ex)
            {
                Assert.Fail(ex.Message);
            }

        }
Esempio n. 7
0
        public void updateUserPropertiesTest()
        {
            string login = "******" + random.Next();
            BackendlessUser user = new BackendlessUser { };
            user.SetProperty("email", "*****@*****.**");
            user.SetProperty("login", login);
            user.Password = "******";
            try
            {
                Backendless.UserService.Register(user);
                BackendlessUser user2 = Backendless.UserService.Login(login, "111222");
                user2.SetProperty("email", "*****@*****.**");
                user2.Password = "******";
                BackendlessUser user3 = Backendless.UserService.Update(user2);
                Assert.AreEqual("*****@*****.**", user3.Properties["email"], "Server returned wrong user email");
                Assert.AreEqual("111111", user3.Password, "Server returned wrong user password");

            }
            catch (System.Exception e)
            {
                Assert.Fail(e.Message);
            }
            
        }
Esempio n. 8
0
 public void registerWithIntValueTest()
 {
     BackendlessUser user = new BackendlessUser { };
     user.SetProperty("email", "*****@*****.**");
     user.SetProperty("login", 1234);
     user.Password = "******";
     BackendlessUser expected = new BackendlessUser();
     try
     {
         expected = Backendless.UserService.Register(user);
     }
     catch (BackendlessException e)
     {
         //Wrong value type for property 'login'.
         Assert.AreEqual("3049", e.Code);
     }
 }
Esempio n. 9
0
 public void loginWithProperStringValueTest()
 {
     try
     {
         string login = "******" + random.Next();
         BackendlessUser user = new BackendlessUser { };
         user.SetProperty("email", login + "@hotmail.com");
         user.SetProperty("login", login);
         user.Password = "******";
         Backendless.UserService.Register(user);
         BackendlessUser expected = Backendless.UserService.Login(login, "111222");
         Assert.IsNotNull(expected);
     }
     catch (BackendlessException ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Esempio n. 10
0
        public void getCurrentUserTest()
        {
            string login = "******" + random.Next();
            AsyncCallback<BackendlessUser> callback = new AsyncCallback<BackendlessUser>(
            u =>
            {
                Assert.AreEqual(UserService.CurrentUser, login);
            },
            f =>
            {
                Assert.Fail(f.Message);
            });
            AsyncCallback<BackendlessUser> regCallback = new AsyncCallback<BackendlessUser>(
            u =>
            {
                Backendless.UserService.Login(login, "111222",callback);
            },
            f =>
            {
                Assert.Fail(f.Message);
            });
            BackendlessUser user = new BackendlessUser { };
            user.SetProperty("email", "*****@*****.**");
            user.SetProperty("login", login);
            user.Password = "******";
            Backendless.UserService.Register(user,regCallback);
            

        }
Esempio n. 11
0
 public void registerWithNullEmailTest()
 {
     
     try
     {
         BackendlessUser user = new BackendlessUser { };
         user.SetProperty("email", null);
         user.SetProperty("login", "test001");
         user.Password = "******";
         BackendlessUser expected = new BackendlessUser();
         expected = Backendless.UserService.Register(user);
         Assert.IsNotNull(expected);
     }
     catch (BackendlessException e)
     {
         //Provided email has wrong format.
         Assert.AreEqual("3040", e.Code);
     }
 }
Esempio n. 12
0
 public void registerWithNullValueTest()
 {
     AsyncCallback<BackendlessUser> callback = new AsyncCallback<BackendlessUser>(
     u =>
     {
         Assert.IsNotNull(u, "Server returned a null result");
     },
     f =>
     {
         Assert.Fail(f.Message);
     });
     BackendlessUser user = new BackendlessUser { };
     user.SetProperty("email", null);
     user.SetProperty("login", null);
     user.SetProperty("password", null);
     Backendless.UserService.Register(user,callback);
 }
Esempio n. 13
0
 public void loginWithProperStringValueTest()
 {
     AsyncCallback<BackendlessUser> logincallback = new AsyncCallback<BackendlessUser>(
     u =>
     {
         Assert.IsNotNull(u, "Server returned a null result");
     },
     f =>
     {
         Assert.Fail(f.Message);
     });
     AsyncCallback<BackendlessUser> registercallback = new AsyncCallback<BackendlessUser>(
     u =>
     {
         Backendless.UserService.Login(u.Properties["login"].ToString(), u.Password, logincallback);
     },
     f =>
     {
         Assert.Fail(f.Message);
     });
     
     BackendlessUser user = new BackendlessUser { };
     user.SetProperty("email", "*****@*****.**");
     user.SetProperty("login", "test"+random.Next());
     user.Password = "******";
     Backendless.UserService.Register(user,registercallback);
 }
Esempio n. 14
0
 public void registerWithBooleanValueTest()
 {
     AsyncCallback<BackendlessUser> callback = new AsyncCallback<BackendlessUser>(
     u =>
     {
         Assert.IsNotNull(u, "Server returned a null result");
     },
     f =>
     {
         Assert.Fail(f.Message);
     });
     BackendlessUser user = new BackendlessUser { };
     user.SetProperty("email", true);
     user.SetProperty("login", true);
     user.SetProperty("password", "test");
     try
     {
         Backendless.UserService.Register(user, callback);
     }
     catch (BackendlessException ex)
     {
         Assert.AreEqual("3040", ex.Code);
     }
 }
Esempio n. 15
0
 public void registerWithIntValueTest()
 {
     AsyncCallback<BackendlessUser> callback = new AsyncCallback<BackendlessUser>(
     u =>
     {
         Assert.IsNotNull(u, "Server returned a null result");
     },
     f =>
     {
         Assert.Fail(f.Message);
     });
     BackendlessUser user = new BackendlessUser { };
     user.SetProperty("email", "*****@*****.**");
     user.SetProperty("login", 1234);
     user.Password = "******";
     Backendless.UserService.Register(user,callback);
 }
Esempio n. 16
0
 public void registerWithNullEmailTest()
 {
     AsyncCallback<BackendlessUser> callback = new AsyncCallback<BackendlessUser>(
     u =>
     {
         Assert.IsNotNull(u, "Server returned a null result");
     },
     f =>
     {
         Assert.Fail(f.Message);
     });
     string login = "******" + random.Next();
     BackendlessUser user = new BackendlessUser { };
     user.SetProperty("email", null);
     user.SetProperty("login", login);
     user.Password = "******";
     Backendless.UserService.Register(user,callback);
 }
Esempio n. 17
0
 public void registerWithoutLoginAsIdentityTest()
 {
     
     try
     {
         BackendlessUser user = new BackendlessUser { };
         user.SetProperty("email", "*****@*****.**");
         user.Password = "******";
         BackendlessUser expected = new BackendlessUser();
         expected = Backendless.UserService.Register(user);
         Assert.IsNotNull(expected);
     }
     catch (BackendlessException e)
     {
         Assert.AreEqual("3013", e.Code);
     }
 }
Esempio n. 18
0
 public void restorePasswordTest()
 {
     try
     {
         AsyncCallback<object> callback = new AsyncCallback<object>(
         u =>
         {
             Assert.IsNotNull(u);
         },
         f =>
         {
             Assert.Fail(f.Message);
         });
         string login = "******" + random.Next();
         BackendlessUser user = new BackendlessUser();
         user.SetProperty("email", "*****@*****.**");
         user.SetProperty("login", login);
         user.Password = "******";
         Backendless.UserService.Register(user);
         Backendless.UserService.RestorePassword(login, callback);
     }
     catch (BackendlessException ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Esempio n. 19
0
        public void registerWithWrongArgumentsCountTest()
        {

            try
            {
                BackendlessUser user = new BackendlessUser { };

                string login = "******" + random.Next();

                user.SetProperty("email", login + "@hotmail.com");
                user.SetProperty("login", login);
                user.SetProperty("login2", "test002");
                user.SetProperty("password2", "111111");
                user.Password = "******";
                BackendlessUser expected = new BackendlessUser();
                expected = Backendless.UserService.Register(user);
                Assert.IsNotNull(expected);
            }
            catch (System.Exception e)
            {
                Assert.Fail(e.Message);
            }
            
        }
Esempio n. 20
0
 public void registerUserWithProperStringValueTest()
 {
     string login = "******" + random.Next();
     AsyncCallback<BackendlessUser> callback = new AsyncCallback<BackendlessUser>(
     u =>
     {
         Assert.IsNotNull(u, "Server returned a null result");
         Assert.IsNotNull(u.UserId, "Server returned a null id");
         Assert.AreEqual(login, u.Properties["login"], "Server returned wrong user login");
         Assert.AreEqual("*****@*****.**", u.Properties["email"], "Server returned wrong user email");
         Assert.AreEqual("111222", u.Password, "Server returned wrong user password");
     },
     f =>
     {
         Assert.Fail(f.Message);
     });
     
     BackendlessUser user = new BackendlessUser { };
     user.SetProperty("email", "*****@*****.**");
     user.SetProperty("login", login);
     user.Password = "******";
     Backendless.UserService.Register(user, callback);
 }
Esempio n. 21
0
 public void registerWithIntValueAndWrongEmailTest()
 {
     
     try
     {
         BackendlessUser user = new BackendlessUser { };
         user.SetProperty("email", "test.com");
         user.SetProperty("login", 1234);
         user.Password = "******";
         BackendlessUser expected = new BackendlessUser();
         expected = Backendless.UserService.Register(user);
         Assert.IsNotNull(expected);
     }
     catch (BackendlessException e)
     {
         Assert.AreEqual("3040", e.Code);
     }
 }
Esempio n. 22
0
        public void registerWithoutBodyTest()
        {
            BackendlessUser expected = new BackendlessUser();
            try
            {
                expected = Backendless.UserService.Register(null);
                Assert.IsNotNull(expected, "Server returned a null result");
            }
            catch (BackendlessException ex)
            {
                //101
                Assert.AreEqual("N/A", ex.Code);
            }
            

        }
Esempio n. 23
0
 public void registerWithNullValueTest()
 {
     
     try
     {
         BackendlessUser user = new BackendlessUser { };
         user.SetProperty("email", null);
         user.SetProperty("login", null);
         user.SetProperty("password", null);
         BackendlessUser expected = new BackendlessUser();
         expected = Backendless.UserService.Register(user);
         Assert.IsNotNull(expected);
     }
     catch (BackendlessException e)
     {
         Assert.AreEqual("3041", e.Code);
     }
 }
Esempio n. 24
0
        public void registerUserWithoutEmailTest()
        {
            string login = "******" + random.Next();
            BackendlessUser user = new BackendlessUser { };
            user.SetProperty("login", login);
            user.Password = "******";

            BackendlessUser expected = new BackendlessUser();
            try
            {
                expected = Backendless.UserService.Register(user);
                Assert.IsNotNull(expected);
            }
            catch (BackendlessException ex)
            {
                Assert.AreEqual("3012", ex.Code);
            }
            Assert.IsNotNull(expected, "Server returned a null result");
        }
Esempio n. 25
0
 public void loginUserWithInvalidPasswordTest()
 {
     try
     {
         string login = "******" + random.Next();
         BackendlessUser user = new BackendlessUser { };
         user.SetProperty("email", "*****@*****.**");
         user.SetProperty("login", login);
         user.Password = "******";
         Backendless.UserService.Register(user);
         BackendlessUser expected = Backendless.UserService.Login(login, "111111");
         Assert.IsNotNull(expected);
     }
     catch (BackendlessException ex)
     {
         Assert.AreEqual("3003", ex.Code);
     }
 }
 public ActionResult Register(RegisterModel registerModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             BackendlessUser newUser = new BackendlessUser();
             newUser.SetProperty("login", registerModel.Login);
             newUser.SetProperty("email", registerModel.Email);
             newUser.SetProperty("name", registerModel.Name);
             newUser.SetProperty("surname", registerModel.Surname);
             newUser.Password = registerModel.Password;
             Backendless.UserService.Register(newUser);
             return RedirectToAction("Login", "Account");
         }
         catch (BackendlessException exception)
         {
             if (exception.FaultCode == "3033")
             {
                 ModelState.AddModelError("", "Login jest zajęty.");
             }
             else
             {
                 ModelState.AddModelError("", exception.ToString());
             }
         }
     }
     return View(registerModel);
 }
Esempio n. 27
0
 public void restorePasswordTest()
 {
     string login = "******" + random.Next();
     BackendlessUser user = new BackendlessUser();
     user.SetProperty("email", "*****@*****.**");
     user.SetProperty("login", login);
     user.Password = "******";
     Backendless.UserService.Register(user);
     try
     {
         Backendless.UserService.RestorePassword(login);
     }
     catch (BackendlessException ex)
     {
         Assert.Fail(ex.Message);
     }
 }
Esempio n. 28
0
 public void registerWithProperStringValueAndIdTest()
 {
     string login = "******" + random.Next();
     BackendlessUser user = new BackendlessUser { };
     user.SetProperty("email", login + "@hotmail.com");
     user.SetProperty("login", login);
     user.SetProperty("id", "12345");
     user.Password = "******";
     BackendlessUser expected = new BackendlessUser();
     try
     {
         expected = Backendless.UserService.Register(user);
         Assert.IsNotNull(expected);
     }
     catch (BackendlessException e)
     {
         Assert.AreEqual("3039", e.Code);
     }
     //Assert.IsNotNull(expected, "Server returned a null result");
     //Assert.IsNotNull(expected.Id, "Server returned a null id");
     //Assert.AreEqual("test001", expected.Properties["login"], "Server returned wrong user login");
     //Assert.AreEqual("*****@*****.**", expected.Properties["email"], "Server returned wrong user email");
     //Assert.AreEqual("12345", expected.Properties["id"], "Server returned wrong user id");
     //Assert.AreEqual("111222", expected.Password, "Server returned wrong user password");
 }
Esempio n. 29
0
 public void registerCopyUserWithIdentityTest()
 {
     
     try
     {
         string login = "******" + random.Next();
         BackendlessUser user = new BackendlessUser { };
         user.SetProperty("email", "*****@*****.**");
         user.SetProperty("login", login);
         user.Password = "******";
         BackendlessUser actual= Backendless.UserService.Register(user);
         BackendlessUser user2 = new BackendlessUser { };
         user2.SetProperty("email", "*****@*****.**");
         user2.SetProperty("login", login);
         user2.Password = "******";
         BackendlessUser expected = Backendless.UserService.Register(user2);
         Assert.AreEqual(expected, actual);
     }
     catch (BackendlessException ex)
     {
         Assert.AreEqual("3033", ex.Code);
     }
     
 }
Esempio n. 30
0
        public void registerCopyUserWithIdentityTest()
        {
            string login = "******" + random.Next();
            AsyncCallback<BackendlessUser> callback1 = new AsyncCallback<BackendlessUser>(
             user =>
             {
                
                 Assert.IsNotNull(user, "Server returned a null result");
             },
             fault =>
             {
                 Assert.Fail(fault.Message);
             });
            AsyncCallback<BackendlessUser> callback2 = new AsyncCallback<BackendlessUser>(
             user =>
             {
                 BackendlessUser u2 = new BackendlessUser { };
                 u2.SetProperty("email", "*****@*****.**");
                 u2.SetProperty("login", login);
                 u2.Password = "******";
                 Backendless.UserService.Register(u2, callback1);
             },
             fault =>
             {
                 Assert.Fail(fault.Message);
             });
           
            BackendlessUser u = new BackendlessUser { };
            u.SetProperty("email", "*****@*****.**");
            u.SetProperty("login", login);
            u.Password = "******";
            Backendless.UserService.Register(u,callback2);

        }