/// <summary> /// Triggered by clicking the register button on RegisterPage to /// create new authors /// </summary> public async void OnRegister(object sender, EventArgs e) { if (newAuthorFirstName.Text != null && newAuthorLastName.Text != null && newAuthorEmail.Text != null && newAuthorDateOfBirth.Date != null && newAuthorUsername.Text != null && newAuthorPassword.Text != null && newAuthorPassword.Text == newAuthorConfirmPassword.Text) { // Show loading indicator UserDialogs.Instance.ShowLoading("Loading", MaskType.Black); // New author object var author = new Author { FirstName = newAuthorFirstName.Text, LastName = newAuthorLastName.Text, Email = newAuthorEmail.Text, DateOfBirth = newAuthorDateOfBirth.Date, Username = newAuthorUsername.Text.ToLower(), Password = AppHelper.GeneratePasswordHash( newAuthorPassword.Text ) }; // Register author await RegisterAuthor(author); // Hide loading indicator UserDialogs.Instance.HideLoading(); // Go back to login page on success if (this.errored != true) { await Navigation.PopToRootAsync(); } } else { if (newAuthorUsername.Text == null) { await DisplayAlert("Error", "Your username can't be empty!", "Try again"); } else if (newAuthorFirstName.Text == null) { await DisplayAlert("Error", "Your first name can't be empty!", "Try again"); } else if (newAuthorLastName.Text == null) { await DisplayAlert("Error", "Your last name can't be empty!", "Try again"); } else if (newAuthorEmail.Text == null) { await DisplayAlert("Error", "Your email address can't be empty!", "Try again"); } else if (newAuthorDateOfBirth.Date == null) { await DisplayAlert("Error", "Your date of birth can't be empty!", "Try again"); } else if (newAuthorPassword.Text == null) { await DisplayAlert("Error", "Your password can't be empty!", "Try again"); } else if (newAuthorPassword.Text != newAuthorConfirmPassword.Text) { await DisplayAlert("Error", "Your passwords don't match!", "Try again"); } } }