public bool IsValidEmail(string emailAddress) { try { return(_validationHelper.IsValidEmail(emailAddress)); } catch (Exception ex) { DependencyService.Get <IMetricsManagerService>().TrackException("EmailValidationFailure", ex); return(false); } }
private async void SaveProfile() { // Check if any of the required fields are empty or invalid if (string.IsNullOrWhiteSpace(FirstName) || string.IsNullOrWhiteSpace(LastName) || string.IsNullOrWhiteSpace(Email) || string.IsNullOrWhiteSpace(MobilePhone) || (string.IsNullOrEmpty(Email) || !_validationHelper.IsValidEmail(Email)) || (string.IsNullOrEmpty(MobilePhone) || !_validationHelper.IsValidPhone(MobilePhone))) { var @continue = await App.DisplayAlertAsync("Profile Incomplete", "The profile information is not complete - do you want to save anyway, or go back to correct it?", "Continue", "Cancel"); if (!@continue) { return; } } try { SaveButtonText = "Saving..."; IsBusy = true; SaveProfileCommand.ChangeCanExecute(); DependencyService.Get <IMetricsManagerService>().TrackEvent("SaveVolunteer"); await SurveyCloudService.SaveVolunteerAsync(UserSettings.Volunteer); SaveButtonText = "Saved!"; UpdateCurrentInfo(); IsBusy = false; SaveProfileCommand.ChangeCanExecute(); await Task.Delay(SaveButtonMessageDelay); } catch (Exception ex) { DependencyService.Get <IMetricsManagerService>().TrackException("SaveVolunteerFailed", ex); await App.DisplayAlertAsync("Profile Save Error", "Failed to update profile information. Please try again later.", "OK"); } finally { IsBusy = false; SaveProfileCommand.ChangeCanExecute(); SaveButtonText = DefaultSaveButtonText; } }
private void HandleTextChanged(object sender, TextChangedEventArgs e) { var isValid = s_validationHelper.IsValidEmail(e.NewTextValue); ((Entry)sender).TextColor = isValid ? Color.Default : Color.Red; }