async private void teacherRegisterButtonCick(object sender, EventArgs e) { /// <summary> /// Subroutine that is executed when the register button is pressed after the teacher registration /// form has been completed. This method ensures that all values are != "", before checking passwords /// are matching. The adminCode may be correct and a MessageBox is shown when this occurs. /// </summary> string forename = forenameTextBox.Text; string surname = surnameTextBox.Text; string password = passwordRegistrationTextBox.Text; string confirmedPassword = confirmPasswordRegistrationTextbox.Text; string title = titleTextBox.Text; string adminCode = adminCodeTextBox.Text; string username = usernameRegistrationTextBox.Text; if (forename == "" || surname == "" || password == "" || confirmedPassword == "" || title == "" || adminCode == "" || adminCode == "") { MessageBox.Show("All values must be entered"); return; } if (password != confirmedPassword) { MessageBox.Show("Passwords do not match!"); return; } if (!User.IsPasswordValid(password)) { MessageBox.Show("The password is not strong enough. It must have:\nlength of 8\n1 or more uppercase letters\n1 or more lowercase letters\n1 or more digits."); return; } try { Teacher teacher = await APIHandler.MakeTeacher(forename, surname, username, password, title, adminCode : adminCode); MessageBox.Show("Registration complete, you can now go back and log in."); flushTextBoxes(); } catch (HttpStatusUnauthorized) { MessageBox.Show("Incorrect admin code entered."); } catch (HttpRequestException) { MessageBox.Show("That username has already been used, please try again with a different username."); } }