public DataCleanEventFactoryAutoFixTests() { _dataCleanEventFactory = new DataCleanEventFactory( new DataCleaner.DataCleaner(ConfigurationManager.AppSettings) , new DataCleanRespository(),_criteria = new DataCleanCriteria() { AutoFixAddressLine1 = false, AutoFixCity = false, AutoFixPostalCode = false, AutoFixState = false, ForceValidation = true }); }
public DataCleanEventController() { var c = ConfigurationManager.AppSettings; var criteria = new DataCleanCriteria() { AutoFixAddressLine1 = false, AutoFixCity = false, AutoFixPostalCode = true, AutoFixState = false, ForceValidation = false }; _dcef = new DataCleanEventFactory(new DataCleaner(c), new DataCleanRespository(), criteria); }
protected override void Execute(Csla.Rules.RuleContext context) { var target = (VoucherEdit)context.Target; string firstName = (string)ReadProperty(target, FirstProperty); string lastName = (string)ReadProperty(target, LastProperty); string companyName = (string)ReadProperty(target, CompanyProperty); string address1 = (string)ReadProperty(target, AddressLine1Property); string municipality = (string)ReadProperty(target, MunicipalityProperty); string postalCode = (string)ReadProperty(target, PostalCodeProperty); if (!string.IsNullOrEmpty(firstName + lastName + companyName) && !string.IsNullOrEmpty(address1) && !string.IsNullOrEmpty(municipality) && !string.IsNullOrEmpty(postalCode) && target.IsDirty ) { //if a complete address then verify against web service var config = ConfigurationManager.AppSettings; var dataCleanEventFactory = new DataCleanEventFactory( new DataCleaner(config), new DataCleanRespository(), new DataCleanCriteria() { AutoFixAddressLine1 = false, AutoFixCity = false, AutoFixPostalCode = false, AutoFixState = false, ForceValidation = false }); var inputAddress = new InputStreetAddress() { AddressLine1 = target.AddressLine1, AddressLine2 = target.AddressLine2, City = target.Municipality, CompanyName = target.Company, Country = target.Country, FirstName = target.First, FullName = target.FullName, LastName = target.Last, PostalCode = target.PostalCode, State = target.Region }; var dataCleanEvent = dataCleanEventFactory.ValidateAddress(inputAddress); if (!dataCleanEvent.Output.OkMailingAddress) { var errStr = string.Empty; foreach (var err in dataCleanEvent.Output.Errors) { context.AddErrorResult(err.LongDescription); } } } }