private ValidationModel ValidateAllFieldsComplete(PersonModel person) { var response = new ValidationModel { ErrorMessage = "Please Complete all fields.", IsValid = false }; var validateName = person.Email.Length > 0 & person.Name.Length > 0 & person.Phone.Length > 0; if (validateName) response.IsValid = true; return response; }
public ValidationModel ValidatePerson(PersonModel person) { ValidationModel checkvalidation; checkvalidation = ValidateAllFieldsComplete(person); if (checkvalidation.IsValid) { checkvalidation = ValidateEmail(person.Email); if (checkvalidation.IsValid) checkvalidation = IsPhone(person.Phone); } return checkvalidation; }
private async void saveButton_Click(object sender, RoutedEventArgs e) { var person = new PersonModel(firstNameTextBox.Text, emailAddressTextBox.Text, PhoneNumberTextBox.Text); var validation = new PersonBusiness(); var validate = validation.ValidatePerson(person); if (validate.IsValid) { var loadExistingData = await ApplicationUtilities.GetSavedUsers(); var storageHelper = new StorageHelper<List<PersonModel>>(StorageType.Local); if (loadExistingData == null) { var peopleList = new List<PersonModel> { person }; storageHelper.SaveASync(peopleList, "Settings"); } else { loadExistingData.Add(person); storageHelper.SaveASync(loadExistingData, "Settings"); } ErrorMessageTextBlock.Text = "Saved..."; ClearUserEntry(); } else { ErrorMessageTextBlock.Text = validate.ErrorMessage; } saveButton.Focus(FocusState.Keyboard); }
private static string PrintPersonModel(PersonModel model) { return (model.Name + "," + model.Email + "," + model.Phone + Environment.NewLine); }