public ActionResult CreateAccount(UserViewModel userViewModel, string password, string passwordValidation) { try { if (password == passwordValidation) { switch (userViewModel.UserAccountType) { case global::Models.User.AccountType.CareRecipient: _userLogic.AddNewUser(new CareRecipient(userViewModel.FirstName, userViewModel.LastName, userViewModel.Address, userViewModel.City, userViewModel.PostalCode, userViewModel.EmailAddress, Convert.ToDateTime(userViewModel.BirthDate), (User.Gender)Enum.Parse(typeof(User.Gender), userViewModel.UserGender), true, global::Models.User.AccountType.CareRecipient, password)); break; case global::Models.User.AccountType.Admin: _userLogic.AddNewUser(new Admin(userViewModel.FirstName, userViewModel.LastName, userViewModel.Address, userViewModel.City, userViewModel.PostalCode, userViewModel.EmailAddress, Convert.ToDateTime(userViewModel.BirthDate), (User.Gender)Enum.Parse(typeof(User.Gender), userViewModel.UserGender), true, global::Models.User.AccountType.Admin, password)); break; default: _userLogic.AddNewUser( new Volunteer(userViewModel.FirstName, userViewModel.LastName, userViewModel.Address, userViewModel.City, userViewModel.PostalCode, userViewModel.EmailAddress, Convert.ToDateTime(userViewModel.BirthDate), (User.Gender)Enum.Parse(typeof(User.Gender), userViewModel.UserGender), true, global::Models.User.AccountType.Volunteer, password)); break; } } else { ViewBag.Message = "De wachtwoorden komen niet overheen"; return(View()); } } catch (FormatException) { ViewBag.Message = "De geboortedatum is onjuist ingevoerd"; return(View()); } return(RedirectToAction("Login")); }
private void addUserButton_Click(object sender, EventArgs e) { AppEnum.UserLevel userLevel = (AppEnum.UserLevel)Enum.Parse(typeof(AppEnum.UserLevel), userLevelComboBox.Text); int affectedRows = userLogic.AddNewUser(usernameTextBox.Text, passwordTextBox.Text, (int)userLevel, emailTextBox.Text); RefreshUserList(); }
public void AddNewUser_IsValid() { _mockContext.Setup(x => x.AddNewUser(_user)); UserLogic userLogic = new UserLogic(_mockContext.Object); userLogic.AddNewUser(_user); _mockContext.Verify(x => x.AddNewUser(_user), Times.Exactly(1)); }
private void addUserBtn_Click(object sender, EventArgs e) { //TODO for assignment: MAKE SURE PASSWORD VALIDATION IS GOOD AND NO FIELDS ARE LEFT EMPTY //Note: Combobox holds a list of strings, so we convert that string to the actual enum value it reperesents AppEnum.UserLevel userLevel = (AppEnum.UserLevel)Enum.Parse(typeof(AppEnum.UserLevel), userLevelCombo.Text); //we pass all the values to AddNewUser. We can cast enums to ints to get their numeric value userLogic.AddNewUser(usernameTextBox.Text, passwordTextBox.Text, (int)userLevel, emailTextBox.Text); RefreshUserList(); }
//Add user button private void addUserButton_Click(object sender, EventArgs e) { //get enum back out of datasource of combo box........ AppEnum.UserLevel userLevel = (AppEnum.UserLevel)Enum.Parse(typeof(AppEnum.UserLevel), userLevelComboBox.Text); int affectedRows = userLogic.AddNewUser(userNameTextBox.Text, passwordTextBox.Text, (int)userLevel, emailTextBox.Text); //if affectedRows > 0, success! RefreshUserList(); }
private void btnAdd_Click(object sender, EventArgs e) { User newProfessional = new Professional(tbFirstName.Text, tbLastName.Text, tbAddress.Text, tbCity.Text, tbPostalCode.Text, tbEmail.Text, dateOfBirth.Value, (User.Gender)Enum.Parse(typeof(User.Gender), cboxSex.Text), true, User.AccountType.Professional); if (tbPassword.Text == tbPassValidation.Text) { try { UserLogic.AddNewUser(newProfessional, tbPassword.Text); MessageBox.Show("Professional toegevoegd"); } catch (Exception exception) { MessageBox.Show("mislukt" + exception); } } }
private void btnAddUser_Click(object sender, EventArgs e) { List <UserModel> users = _userLogic.GetListOfUsers(); if (txtUserName.Text == "" && txtPassword.Text == "" && txtAddConfirmPW.Text == "" && txtEmail.Text == "") { lbStripStatus.Text = "Missing some information"; MessageBox.Show("Please fill all form"); return; } else if (txtPassword.Text != txtAddConfirmPW.Text) { lbStripStatus.Text = "Your password does not match"; MessageBox.Show("Password dose not match"); return; } else if (!(txtPassword.Text.Any(char.IsLower) && txtPassword.Text.Any(char.IsUpper) && txtPassword.Text.Any(char.IsDigit) && (txtPassword.Text.Length > 8))) { lbStripStatus.Text = "Password must have minimum 1 Uppercase, 1 Lowercase , 1 Number and 8 characters"; MessageBox.Show("Password have condition"); return; } for (int i = 0; i < users.Count; i++) { if (users[i].UserName == txtUserName.Text) { lbStripStatus.Text = "User Name has already"; MessageBox.Show("User Name has already!"); return; } } //TODO for assignment: MAKE SURE PASSWORD VALIDATION IS GOOD AND NO FIELDS ARE LEFT EMPTY //NOTE: Combobox holds a list of strings, so we convert that string to the actural enum value it repersents AppEnum.UserLevel userLevel = (AppEnum.UserLevel)Enum.Parse(typeof(AppEnum.UserLevel), cbUserLevel.Text); //We pass all the Values to AddNewUser. We can cafst enums to ints to get their numeric value //userLogic.AddNewUser(txtUserName.Text, txtPassword.Text, cbUserLevel.SelectedIndex + 1, txtEmail.Text); _userLogic.AddNewUser(txtUserName.Text, txtPassword.Text, (int)userLevel, txtEmail.Text); RefreshUserList(); }
private void btnAddUser_Click(object sender, EventArgs e) { if (tbPassword.Text != tbPassValidation.Text) { MessageBox.Show("Wachtwoord komt niet overeen!"); } else { if (UserLogic.CheckIfUserAlreadyExists(tbEmail.Text)) { if (UserLogic.IsEmailValid(tbEmail.Text)) { string accountType = "CareRecipient"; if (rbtnVolunteer.Checked) { accountType = "Volunteer"; } else if (rbtnCareRecipient.Checked) { accountType = "CareRecipient"; } User.Gender gender = (User.Gender)Enum.Parse(typeof(User.Gender), cboxSex.Text); UserLogic.AddNewUser(tbFirstName.Text, tbLastName.Text, dateOfBirth.Value, gender, tbEmail.Text, tbAddress.Text, tbPostalCode.Text, tbCity.Text, tbPassword.Text, accountType); ((MainForm)this.Parent.Parent).ReplaceForm(new LoginPrototype()); } else { MessageBox.Show("Email is verkeerd!"); } } else { MessageBox.Show("Gebruiker bestaat al!"); } } }
public int InsertNewUser(String UserName, String Password, int UserLevel, String Email) { UserLogic userLogic = new UserLogic(); return(userLogic.AddNewUser(UserName, Password, UserLevel, Email)); }
public int addNewUsers(string username, string password, int userLevel, string email, int adminLevel) { return(ul.AddNewUser(username, password, userLevel, email, adminLevel)); }
public ActionResult CreateAccount(UserViewModel userViewModel, string password, string passwordValidation) { try { if (password == passwordValidation) { if (_userLogic.CheckIfUserAlreadyExists(userViewModel.EmailAddress)) { if (_userLogic.IsEmailValid(userViewModel.EmailAddress)) { switch (userViewModel.UserAccountType) { case global::Models.User.AccountType.CareRecipient: _userLogic.AddNewUser(new CareRecipient(userViewModel.FirstName, userViewModel.LastName, userViewModel.Address, userViewModel.City, userViewModel.PostalCode, userViewModel.EmailAddress, Convert.ToDateTime(userViewModel.BirthDate), (User.Gender)Enum.Parse(typeof(User.Gender), userViewModel.UserGender), true, global::Models.User.AccountType.CareRecipient, password)); break; case global::Models.User.AccountType.Admin: _userLogic.AddNewUser(new Admin(userViewModel.FirstName, userViewModel.LastName, userViewModel.Address, userViewModel.City, userViewModel.PostalCode, userViewModel.EmailAddress, Convert.ToDateTime(userViewModel.BirthDate), (User.Gender)Enum.Parse(typeof(User.Gender), userViewModel.UserGender), true, global::Models.User.AccountType.Admin, password)); break; default: _userLogic.AddNewUser( new Volunteer(userViewModel.FirstName, userViewModel.LastName, userViewModel.Address, userViewModel.City, userViewModel.PostalCode, userViewModel.EmailAddress, Convert.ToDateTime(userViewModel.BirthDate), (User.Gender)Enum.Parse(typeof(User.Gender), userViewModel.UserGender), true, global::Models.User.AccountType.Volunteer, password)); break; } } else { ViewBag.Message = "Foutieve email ingevoerd"; return(View()); } } else { ViewBag.Message = "Er bestaat al een account met deze e-mail"; return(View()); } } else { ViewBag.Message = "De wachtwoorden komen niet overheen"; return(View()); } } catch (Exception) { ViewBag.Message = "De gebruiker is niet aangemaakt"; return(View()); } return(RedirectToAction("Login")); }