Beispiel #1
0
        /// <summary>
        /// When user clicks on create an account
        /// </summary>
        /// <param name="sender">System.Windows.Forms.Button</param>
        /// <param name="e">System.Windows.Forms.MouseEventArgs</param>
        private void NewUserBtn_Click(object sender, EventArgs e)
        {
            Hide();
            NewUserForm newUserForm = new NewUserForm();

            newUserForm.Show();
        }
Beispiel #2
0
        // Shows a registration form and hide login form
        public static void ShowNewUserForm(LoginForm loginForm)
        {
            NewUserForm newUserForm = new NewUserForm();

            loginForm.Hide();
            newUserForm.Show();
        }
        public string Registeration(NewUserForm newUser)
        {
            var db           = new DBConnector();
            var queryBuilder = new StringBuilder("SELECT COUNT(*) FROM users WHERE username = @user");
            var command      = new MySqlCommand(queryBuilder.ToString());

            command.Parameters.AddWithValue("@user", newUser.username);
            int result = (int)db.ExecuteScalar(command);

            if (result > 0)
            {
                return("username taken");
            }

            queryBuilder = new StringBuilder("SELECT COUNT(*) FROM users WHERE phone = @phone");
            command      = new MySqlCommand(queryBuilder.ToString());
            command.Parameters.AddWithValue("@phone", newUser.phone);
            result = (int)db.ExecuteScalar(command);
            if (result > 0)
            {
                return("phone taken");
            }
            //now we know the user is actually new, start by creating a registeration serial
            int registerSerial = (new Random().Next(100000, 999999));

            queryBuilder = new StringBuilder("SELECT MAX(userID) FROM users");
            command      = new MySqlCommand(queryBuilder.ToString());
            result       = (int)db.ExecuteScalar(command);

            queryBuilder = new StringBuilder("INSERT INTO users (userID, username, password, firstname, lastname, gender, ")
                           .Append("phone, email, address, city, state, country, postal, aboutme, wishlist, registerSerial) VALUES ('")
                           .Append(result)
                           .Append("', '@username', '@password', '@firstname', '@lastname', '@gender', '@phone', '@email', '@address'")
                           .Append(", '@city', '@state', '@country', '@postal', '@aboutme', '@wishlist', '@registerSerial')");
            command.Parameters.AddWithValue("@username", newUser.username);
            command.Parameters.AddWithValue("@password", newUser.password);
            command.Parameters.AddWithValue("@firstname", newUser.firstName);
            command.Parameters.AddWithValue("@lastename", newUser.lastName);
            command.Parameters.AddWithValue("@gender", newUser.gender);
            command.Parameters.AddWithValue("@phone", newUser.phone);
            command.Parameters.AddWithValue("@email", newUser.email);
            command.Parameters.AddWithValue("@address", newUser.address);
            command.Parameters.AddWithValue("@city", newUser.city);
            command.Parameters.AddWithValue("@state", newUser.state);
            command.Parameters.AddWithValue("@country", newUser.country);
            command.Parameters.AddWithValue("@postal", newUser.postal);
            command.Parameters.AddWithValue("@aboutme", newUser.aboutMe);
            command.Parameters.AddWithValue("@wishlist", newUser.wishList);
            command.Parameters.AddWithValue("@registerSerial", registerSerial.ToString());
            result = db.ExecuteNonQuery(command);
            db.CloseConnection();
            if (result > 0)
            {
                return("success");
            }
            else
            {
                return("failed");
            }
        }
Beispiel #4
0
        private void NewUser_bt_Click(object sender, EventArgs e)
        {
            NewUserForm uf = new NewUserForm();

            uf.Show();
            this.Close();
        }
Beispiel #5
0
        public IActionResult CreateUser([FromBody] NewUserForm req)
        {
            var res = new BaseResponse();

            try
            {
                var createdUser = manager.CreateUser(req.NewUser);
                if (createdUser)
                {
                    res.Code = 200;
                    res.HasBeenSuccessful = true;
                    return(Ok(res));
                }

                res.Code = 403;
                res.HasBeenSuccessful = false;
                return(Ok(res));
            }
            catch (Exception e)
            {
                res.Code = 501;
                res.HasBeenSuccessful = false;
                return(Ok(res));
            }
        }
Beispiel #6
0
 public UserCreator(NewUserForm form)
 {
     NewUser       = new User();
     WasTCVerify   = false;
     WasGLogin     = false;
     WaSSetSetting = false;
     Form          = form;
 }
Beispiel #7
0
        private void yeniKullanıcıToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewUserForm newUserForm = new NewUserForm();

            newUserForm.MdiParent   = this;
            newUserForm.WindowState = FormWindowState.Maximized;
            newUserForm.Show();
        }
Beispiel #8
0
 /// <summary>
 /// Function to convert API NewUserForm to Client NewUser
 /// </summary>
 /// <param name="newUser">Client NewUser</param>
 /// <returns>API NewUserForm</returns>
 public static CL.Users.NewUser ToClient(this NewUserForm newUser)
 {
     if (newUser == null)
     {
         return(null);
     }
     return(new CL.Users.NewUser
     {
         Email = newUser.Email,
         BirthDate = newUser.BirthDate,
         Password = newUser.Password
     });
 }
Beispiel #9
0
        private void NewPersonnelButton_Click(object sender, EventArgs e)
        {
            NewUserForm form = new NewUserForm();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Personnel personnel = form.Personnel;

            ViewModelGlobals.Personnels.Add(personnel);
            UpdateView();
        }
 public IActionResult Register([FromBody, SwaggerRequestBody("Form new User", Required = true)] NewUserForm newUser)
 {
     try
     {
         return(Ok(Service.Create(newUser.ToClient())));
     }
     catch
     {
         return(new BadRequestObjectResult(new ExceptionResponse()
         {
             Status = 400, Value = "Form is Invalid"
         }));
     }
 }
Beispiel #11
0
        // Shows a login form and hide text editor or registration form
        public static void ShowLoginForm(NewUserForm newUserForm = null, TextEditorForm textEditorForm = null)
        {
            LoginForm loginForm = new LoginForm();

            if (newUserForm != null)
            {
                newUserForm.Hide();
            }

            if (textEditorForm != null)
            {
                textEditorForm.Hide();
            }
            loginForm.Show();
        }
Beispiel #12
0
 void AddNewUser()
 {
     ActionHelper.Execute(delegate
     {
         var userForm    = new NewUserForm(_systemDomain, _domainName, _serverDto, _tenantName);
         var context     = this.GetApplicationContext();
         var dataContext = context.NavigationController.NavigateToView(this, userForm);
         if (dataContext != null)
         {
             var userDto = (UserDto)dataContext;
             MMCDlgHelper.ShowMessage(string.Format("User {0} created successfully", userDto.Name));
             DoRefresh();
         }
     }, null);
 }
Beispiel #13
0
        private void btn_AddUser_Click(object sender, EventArgs e)
        {
            NewUserForm _form = new NewUserForm();

            if (_form.ShowDialog() == DialogResult.OK)
            {
                {
                    DataTable _dt = (new DAL.DAL_UserInfo()).selectUserInfoListWithKeyAndGroup("");

                    if (_dt != null)
                    {
                        this.UserInfoListView.DataSource = _dt;
                    }
                }
            }
        }
Beispiel #14
0
        public async Task <IActionResult> CreateNewUser(NewUserForm newUserForm, string returnUrl = null)
        {
            if (ModelState.IsValid)
            {
                var user = new UserInfo();

                // Generate blockchain address
                var ecKey      = Nethereum.Signer.EthECKey.GenerateKey();
                var privatekey = ecKey.GetPrivateKeyAsBytes().ToHex();
                var account    = new Nethereum.Web3.Accounts.Account(privatekey);

                user.UserName          = newUserForm.UserName;
                user.Email             = newUserForm.EmailAddress;
                user.FirstName         = newUserForm.FirstName;
                user.LastName          = newUserForm.LastName;
                user.TwoFactorEnabled  = true;
                user.BlockchainAddress = account.Address;
                user.PrivateKey        = account.PrivateKey;
                user.EmailConfirmed    = true;

                var result = await userManager.CreateAsync(user, newUserForm.Password);

                if (result.Succeeded)
                {
                    await this.signInManager.SignInAsync(user, false);

                    return(RedirectToAction(nameof(GetDualAuthCode), new { returnUrl }));
                }
                else
                {
                    foreach (var failure in result.Errors)
                    {
                        ModelState.AddModelError(String.Empty, failure.Description);
                    }
                    return(View(newUserForm));
                }
            }
            return(View(newUserForm));
        }
Beispiel #15
0
        public string Post([FromBody] NewUserForm value)
        {
            DBRequest request = new DBRequest();

            return(request.Registeration(value));
        }
Beispiel #16
0
 public ActionResult NewUserFormAction(NewUserForm newUserForm)
 {
     //process posted form, possibly map / convert it to User then call to save
     _membershipAndRoleService.ProcessNewUser(user);
     //redirect or return view
 }