protected void Page_Load(object sender, EventArgs e) { ddlCountry.DataSource = Countries; ddlCountry.DataBind(); if (!IsPostBack) { if (Address != null) { ddlCountry.SelectedValue = Address.Country.Name; if (!ddlCountry.SelectedValue.Equals("United States")) { txtCity.Enabled = true; txtState.Enabled = true; revZipUS.ValidationExpression = @"\d{1,10}"; revZipUS.ToolTip = "Please, enter correct zip (no more than 10 digits)."; } txtZipCode.Text = Address.ZipCode; txtCity.Text = Address.City; txtState.Text = Address.State; ucStreet.Text = Address.Street; if (Address.AddressID.HasValue) { hfdAddressID.Value = Address.AddressID.ToString(); } } } else { if (string.IsNullOrWhiteSpace(ucStreet.Text) && string.IsNullOrWhiteSpace(txtZipCode.Text)) { Address = null; return; } Address = new Address(); Address.Country = new Country() {Name = ddlCountry.SelectedValue}; Address.ZipCode = txtZipCode.Text; Address.State = txtState.Text; Address.Street = ucStreet.Text; Address.City = txtCity.Text; if (!string.IsNullOrEmpty(hfdAddressID.Value)) { Address.AddressID = int.Parse(hfdAddressID.Value); } } if(!IsPostBack) { if(IsSubjectPropertyAddress) { divAddressUnknown.Visible = true; lblCountry.Visible = false; ddlCountry.Visible = false; if (Address != null && Address.Street == UnknownAddress) { chkAddressUnknown.Checked = true; ucStreet.HideValidator = true; ucStreet.UpdateOnLoad = true; ucStreet.TxtAddressLine.Enabled = false; } } else { divAddressUnknown.Visible = false; } } }
protected void btnClickUpdate(object sender, EventArgs e) { hfSelectedTab.Value = _tabAddressValidation; Country country = new Country(); int validationID = GetValidationID(); CCTLeadProvider provider = new CCTLeadProvider(); AddressValidationRezult avRezult = new AddressValidationRezult(); Address address = new Address(); avRezult = LeadValidationManager.GetAddressValidationInformation(validationID); var viAddress = LeadValidationManager.GetValidationInformation(validationID); address.AddressID = viAddress.Lead.SubjectPropertyAddress.AddressID; address.City = avRezult.CorrectAddress.City; country.Name = viAddress.Lead.SubjectPropertyAddress.Country.Name; address.Country = country; address.State = avRezult.CorrectAddress.State; address.Street = avRezult.CorrectAddress.Address; address.ZipCode = avRezult.CorrectAddress.ZipCode; provider.SaveAddress(address); LeadValidationManager.ChangeStatus(validationID, (int)TypeValidation.AddressValidation, (int)StatusValidation.Passed); lvAddrVal.DataBind(); DataManager.LeadModified(viAddress.Lead.LeadID.Value); }
public static ValidationAddress GetValidAddress(Address address) { StringBuilder queryString; ValidationAddress validationAddress; string addr = address.Street.Replace(' ', '+'); queryString = new StringBuilder(); queryString.Append(_vawf); queryString.Append("?"); queryString.Append("Address="); queryString.Append(addr); if (!string.IsNullOrEmpty(address.City)) { queryString.Append("&City="); queryString.Append(address.City); } else { queryString.Append("&City="); } if (!string.IsNullOrEmpty(address.State)) { queryString.Append("&State="); queryString.Append(address.State); } else { queryString.Append("&State="); } if (!string.IsNullOrEmpty(address.ZipCode)) { queryString.Append("&PostalCode="); queryString.Append(address.ZipCode); } else { queryString.Append("&PostalCode="); } queryString.Append("&LicenseKey="); queryString.Append(_licenseKey); var url = queryString.ToString(); XElement validAddressXml = DownloadOFACBase(url); FragmentAddress validAddress = GetAddressValidation(validAddressXml); validationAddress = ToValidationAddress(validAddress); return validationAddress; }
//public string AddressValidation(int leadID) //{ // ValidationAddress validAddress; // Address currentAddress; // Lead lead = new Lead(); // lead = DataManager.GetLeadById(leadID); // currentAddress = lead.SubjectPropertyAddress; // validAddress = GetValidAddress(currentAddress); // bool isAddressMatch; // if (validAddress.Error == null) // { // if (string.IsNullOrWhiteSpace(validAddress.Address) || (validAddress.Address.ToLower().Equals(currentAddress.Street.ToLower()))) // { // isAddressMatch = true; // } // return validAddress.Address; // } // else // { // return validAddress.Error.Description; // } //} public static bool CompareAddresses(Address currentAddress, ValidationAddress validAddress) { bool isAddressMatch = false; bool isCityMatch = false; // bool isCountryMatch = false; bool isStateMatch = false; bool isZipCodeMatch = false; if (string.IsNullOrWhiteSpace(currentAddress.Street) || currentAddress.Street.ToLower().Equals(validAddress.Address.ToLower())) { isAddressMatch = true; } if (string.IsNullOrWhiteSpace(currentAddress.City) || currentAddress.City.ToLower().Equals(validAddress.City.ToLower())) { isCityMatch = true; } //if (string.IsNullOrWhiteSpace(currentAddress.Country.Name) || currentAddress.Country.Name.ToLower().Equals(validAddress.Country.ToLower())) //{ // isCountryMatch = true; //} if (string.IsNullOrWhiteSpace(currentAddress.State) || currentAddress.State.ToLower().Equals(validAddress.State.ToLower())) { isStateMatch = true; } if (string.IsNullOrWhiteSpace(currentAddress.ZipCode) || currentAddress.ZipCode.ToLower().Equals(validAddress.ZipCode.ToLower())) { isZipCodeMatch = true; } if (isAddressMatch && isCityMatch && isStateMatch && isZipCodeMatch) { return true; } return false; }
private static List<ExclusionaryListEntry> CompareExclListAddress (List<ExclusionaryListEntry> exclusionaryList, Address leadAddress) { List<ExclusionaryListEntry> result = new List<ExclusionaryListEntry>(); if (leadAddress == null || string.IsNullOrWhiteSpace(leadAddress.City) || string.IsNullOrWhiteSpace(leadAddress.Street)) { return result; } if (leadAddress.Country.Name != _nameUSA) { return result; } try { result = exclusionaryList .Where(e => e.City.ToLower() == leadAddress.City.ToLower() && e.State.ToLower() == leadAddress.State.ToLower() && e.Zip == leadAddress.ZipCode && string.Concat(e.AddressLine1, e.AddressLine2, e.AddressLine3).ToLower().Contains(leadAddress.Street.ToLower()) ).ToList(); } catch (NullReferenceException) { return result; } return result; }
private static bool CompareSDNAddress(sdnListSdnEntryAddress sdnAddress, Address leadAddress) { if (leadAddress == null || string.IsNullOrWhiteSpace(leadAddress.City) || string.IsNullOrWhiteSpace(leadAddress.Street)) { return false; } bool isCountryMatch = leadAddress.Country.Name == sdnAddress.country; bool isCityMatch = leadAddress.City == sdnAddress.city; bool isStateMatch = leadAddress.State == sdnAddress.stateOrProvince || string.IsNullOrWhiteSpace(sdnAddress.stateOrProvince); bool isZipMatch = leadAddress.ZipCode == sdnAddress.postalCode || string.IsNullOrWhiteSpace(sdnAddress.postalCode); string mergedAddress = string.Concat(sdnAddress.address1, sdnAddress.address2, sdnAddress.address3); bool isStreetMatch = !string.IsNullOrWhiteSpace(mergedAddress) && !string.IsNullOrWhiteSpace(leadAddress.Street); if (isStreetMatch) { isStreetMatch = mergedAddress.Contains(leadAddress.Street); } if (isCountryMatch && isCityMatch && isStateMatch && isZipMatch && isStreetMatch) { return true; } return false; }
private Address GetAddressEntity(T_Address tAddress) { Address address = new Address(); address.AddressID = tAddress.AddressID; address.City = tAddress.addrCity; address.Country.CountryID = tAddress.CountryID; address.State = tAddress.addrState; address.Street = tAddress.addrStreet; address.ZipCode = tAddress.addrZipCode; return address; }
private Address GetAddressEntity(T_Address tAddress) { Address address = new Address(); using (var dc = new EngageCCTDataClassesDataContext()) { address.AddressID = tAddress.AddressID; address.Street = tAddress.addrStreet; address.City = tAddress.addrCity; address.State = tAddress.addrState; address.ZipCode = tAddress.addrZipCode; address.Country = new Country() { Name = dc.T_Countries.First(el => el.CountryID == tAddress.CountryID).cntName, CountryID = tAddress.CountryID }; address.Coords = tAddress.addrCoords; address.County = tAddress.addrCounty; } return address; }
public int SaveAddress(Address entity) { using (var dc = new EngageCCTDataClassesDataContext()) { T_Address tAddress; if (!entity.AddressID.HasValue) { tAddress = new T_Address(); dc.T_Addresses.InsertOnSubmit(tAddress); } else { tAddress = dc.T_Addresses.SingleOrDefault(a => a.AddressID == entity.AddressID); if (tAddress == null) { throw new ApplicationException("Address not found"); } } tAddress.addrCity = entity.City; tAddress.addrCoords = entity.Coords; if (entity.Country != null) { tAddress.CountryID = dc.T_Countries.First(el => el.cntName == entity.Country.Name).CountryID; } tAddress.addrState = entity.State; tAddress.addrStreet = entity.Street; tAddress.addrZipCode = entity.ZipCode; tAddress.addrCounty = entity.County; dc.SubmitChanges(); return tAddress.AddressID; } }