private static bool CanSave(Contact contact) { OperationResult operationResult; operationResult = null; if (string.IsNullOrEmpty(contact.FirstName)) { operationResult = new OperationResult("First name not set."); } if (string.IsNullOrEmpty(contact.LastName)) { if (operationResult == null) { operationResult = new OperationResult("Last name not set."); } else { operationResult.Errors.Add("Last name not set;"); } } return operationResult ?? new OperationResult(); }
// Helper methods private void DisplayContact(Contact contact) { SuspendLayout(); LoadContactIntoUi(contact); ResumeLayout(); Refresh(); }
private void LoadContactIntoUi(Contact contact) { this.firstNameTextBox.Text = contact.FirstName; this.middleNameTextBox.Text = contact.MiddleName; this.lastNameTextBox.Text = contact.LastName; this.phoneNumberTextBox.Text = contact.PhoneNumber; }
private static OperationResult Save(Contact contact) { // NOTE: (TJ) success would be the real result in a real implementation. // bool success; // TODO: (TJ) Execute Save operation to DB, file, registry, remote call etc. return new OperationResult(); // NOTE: (TJ) success would be the real result in a real implementation. // return success; }