private void ValidateReading(ErrorBucket errors) { if (string.IsNullOrEmpty(txtmeterreading.Text)) { errors.AddError("Please enter meter number"); } }
public void CopyFrom(ErrorBucket donor) { // copy the normal errors... Errors.Clear(); Errors.AddRange(donor.Errors); // copy the fatal error... Fatal = donor.Fatal; }
private void ValidateSignUp(ErrorBucket errors) { if (string.IsNullOrEmpty(username.Text)) { errors.AddError("Enter username"); } if (string.IsNullOrEmpty(password.Password)) { errors.AddError("Enter password"); } if (!string.IsNullOrEmpty(password.Password) && password.Password.Length < 6) { errors.AddError("Password cannot be less than 6 characters"); } }
private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { ErrorBucket errors = new ErrorBucket(); ValidateSignUp(errors); if (!(errors.HasErrors)) { if (NetworkInformation.GetInternetConnectionProfile() == null) { await UIHelper.ShowAlert("Check your internet connection", "No internet connectivity"); } else { await LoginAsync(); } } else { await UIHelper.ShowAlert(errors.GetErrorsAsString()); errors.ClearErrors(); } }
// special constructor for cloning another error bucket... protected ErrorBucket(ErrorBucket donor) : this() { CopyFrom(donor); }