Esempio n. 1
0
        protected void handle_button_oncommand(object sender, CommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "Submit":
                // Create a new user profile.
                NewUserProfile profile = new NewUserProfile();
                profile.EmailAddress = this.email_.Text;
                profile.Password     = this.password_.Text;

                try
                {
                    // Create a new user in the database.
                    this.bmw_.CreateNewUser(profile);

                    // Reset the text for the controls.
                    this.email_.Text = String.Empty;
                }
                catch (Exception)
                {
                }

                break;

            case "Clear":
                break;
            }
        }
        public UserDetails Register(NewUserProfile newUser)
        {
            try
            {
                userProfileDAO.FindByUsername(newUser.Username);

                throw new ArgumentException("Invalid username");
            }
            catch (InstanceNotFoundException)
            {
                try
                {
                    UserProfile userProfile = new()
                    {
                        Role              = "user",
                        Username          = newUser.Username.Trim(),
                        EncryptedPassword = Encrypter.Crypt(newUser.Password.Trim()),
                    };
                    userProfileDAO.Insert(userProfile);

                    return(new UserDetails()
                    {
                        Id = userProfile.Id,
                        Role = userProfile.Role,
                        Username = userProfile.Username
                    });
                }
                catch (SqlException e)
                {
                    throw new ArgumentException(e.Message);
                }
            }
        }
Esempio n. 3
0
 public IActionResult Register([FromBody] NewUserProfile newUser)
 {
     try
     {
         return(StatusCode(StatusCodes.Status201Created, userProfileService.Register(newUser)));
     }
     catch (ArgumentException)
     {
         return(StatusCode(StatusCodes.Status400BadRequest));
     }
 }
        public RegistrationPageViewModel(INavigation navigation, ServerWorker serverWorker, LoginPageViewModel loginPageViewModel = null)
        {
            this.Navigation         = navigation;
            this.loginPageViewModel = loginPageViewModel;
            this.serverWorker       = serverWorker;
            RegistrationStep        = 1;
            ContinueCommand         = new Command(NextPage);
            SignUpCommand           = new Command(SignUp);
            SignInCommand           = new Command(SignIn);

            GoBackCommand = new Command(OnSwipedRight);

            User = new NewUserProfile(serverWorker);
            User.PropertyChanged += (obj, args) => {
                OnPropertyChanged("IsEnabledNextButton");
                OnPropertyChanged("IsEnabledSignUpButton");
            };
            if (loginPageViewModel != null && loginPageViewModel.IsGoogleSignIn)
            {
                User.Name  = loginPageViewModel.User.Name;
                User.Email = loginPageViewModel.User.Email;
                User.CheckNameCorrectness();
                User.CheckEmailCorrectness();
            }


            NameUnfocusedCommand     = new Command(User.CheckNameCorrectness);
            EmailUnfocusedCommand    = new Command(User.CheckEmailCorrectness);
            LoginUnfocusedCommand    = new Command(User.CheckLoginCorrectness);
            PasswordUnfocusedCommand = new Command(() => {
                User.CheckPasswordCorrectness();
                User.CheckConfirmPasswordCorrectness(false);
            }
                                                   );
            ConfirmPasswordUnfocusedCommand = new Command(() => User.CheckConfirmPasswordCorrectness());
            TermsHyperlinkCommand           = new Command(async() =>
            {
                Uri uri = new Uri("https://scigames.ru/terms");
                await Launcher.OpenAsync(uri);
            });
            PolicyHyperlinkCommand = new Command(async() =>
            {
                Uri uri = new Uri("https://scigames.ru/privacy_policy");
                await Launcher.OpenAsync(uri);
            });
        }