/// <summary> /// Add a new user to the database /// </summary> private void btnAdd_Click(object sender, EventArgs e) { UserLogic Logic = new UserLogic(); UserRepository repo = new UserRepository(new UserContext()); if (string.IsNullOrEmpty(tbxEmail.Text) || string.IsNullOrEmpty(tbxPassword.Text) || string.IsNullOrEmpty(tbxRepeat.Text) || string.IsNullOrEmpty(tbxFirstname.Text) || string.IsNullOrEmpty(tbxLastname.Text) || string.IsNullOrEmpty(tbxAddress.Text) || string.IsNullOrEmpty(tbxZipcode.Text) || string.IsNullOrEmpty(tbxPlace.Text)) { lblMessage.Text = "Je mag geen velden leeg laten!"; } else { if (tbxEmail.Text.IndexOf("@") == -1 || tbxEmail.Text.IndexOf(".") == -1) { lblMessage.Text = "E-mailadres is ongeldig"; } else { if (tbxPassword.Text == tbxRepeat.Text) { string password = repo.ComputeHash(tbxPassword.Text, null); User u = new User(tbxEmail.Text, password); u.Firstname = tbxFirstname.Text; u.Lastname = tbxLastname.Text; u.Address = tbxAddress.Text; u.Zipcode = tbxZipcode.Text; u.Place = tbxPlace.Text; Logic.AddUserToSystem(u); AddRoleToUser(u); UserOverview overview = new UserOverview(userEmail); overview.Show(); this.Hide(); } else { lblMessage.Text = "Wachtwoorden zijn niet gelijk aan elkaar."; } } } }