public static void SaveToDatabase(Customer customer) { customer.Validate(); if(customer.IsValid) { // Code to save to the database } else { throw new DataValidationException(); } }
public Workbench() { InitializeComponent(); _customer = new Customer(); txtName.BindTextPropertyTo(_customer, "Name"); txtAddress.BindTextPropertyTo(_customer, "Address"); txtCity.BindTextPropertyTo(_customer, "City"); txtStateCode.BindTextPropertyTo(_customer, "StateCode"); txtZIPCode.BindTextPropertyTo(_customer, "ZIPCode"); txtAge.BindTextPropertyTo(_customer, "Age"); txtPassword.BindTextPropertyTo(_customer, "Password"); txtConfirmPassword.BindTextPropertyTo(_customer, "ConfirmPassword"); txtValue1.BindTextPropertyTo(_customer, "Value1"); txtValue2.BindTextPropertyTo(_customer, "Value2"); }