public static SearchCriteria GetZipCriteria(this SqlDataReader reader) { SearchCriteria searchCriteria = new SearchCriteria(); string valueOrDefault = reader.GetValueOrDefault <string>("Country"); string valueOrDefault2 = reader.GetValueOrDefault <string>("State"); string valueOrDefault3 = reader.GetValueOrDefault <string>("Zip"); string valueOrDefault4 = reader.GetValueOrDefault <string>("City"); if (!valueOrDefault.IsNullOrEmpty()) { searchCriteria.CountryCode(valueOrDefault); } if (!valueOrDefault2.IsNullOrEmpty()) { searchCriteria.StateCode(valueOrDefault2); } if (!valueOrDefault4.IsNullOrEmpty()) { searchCriteria.City(valueOrDefault4); } if (!valueOrDefault3.IsNullOrEmpty()) { searchCriteria.Zip(valueOrDefault3); } return(searchCriteria); }
private SearchCriteria GetLookupCriteria(string lookupLocation, string countryCode) { string str; SearchCriteria searchCriterium = new SearchCriteria(); List <string> list = ( from p in lookupLocation.Split(new char[] { ',' }) select p.Trim()).ToList <string>(); int count = list.Count; if (countryCode == "USA") { str = "^[0-9]*-?[0-9]*$"; } else { str = (countryCode == "CAN" ? "^[a-zA-Z][0-9]([a-zA-Z]( ([0-9]([a-zA-Z][0-9]?)?)?)?)?$" : "^[0-9]+$"); } searchCriterium.CountryCode(countryCode); if (!Regex.IsMatch(list[0], str)) { searchCriterium.StateCode(list[count - 1]); if (count == 2) { searchCriterium.City(list[0]); } else if (count == 3) { searchCriterium.City(list[1]); } } else { searchCriterium.Zip(list[0]); if (count == 2) { searchCriterium.StateCode(list[1]); } else if (count == 3) { searchCriterium.City(list[1]); searchCriterium.StateCode(list[2]); } } return(searchCriterium); }
public static SearchCriteria GetAddressCriteria(this SqlDataReader reader) { SearchCriteria searchCriteria = new SearchCriteria(); string valueOrDefault = reader.GetValueOrDefault <string>("Country"); string valueOrDefault2 = reader.GetValueOrDefault <string>("State"); string valueOrDefault3 = reader.GetValueOrDefault <string>("City"); if (!valueOrDefault.IsNullOrEmpty()) { searchCriteria.CountryCode(valueOrDefault); } if (!valueOrDefault2.IsNullOrEmpty()) { searchCriteria.StateCode(valueOrDefault2); } if (!valueOrDefault3.IsNullOrEmpty()) { searchCriteria.City(valueOrDefault3.SafeToTitleCase()); } return(searchCriteria); }
internal static LookupLocationValidationVm MapToLookupLocationValidationVm(this LookupLocationValidationResult validationResult, SearchType searchType) { LookupLocationValidationVm lookupLocationValidationVm = new LookupLocationValidationVm(); if (validationResult.IsValid && validationResult.Criteria.Depth == SearchDepth.Zip) { SearchCriteria searchCriterium = new SearchCriteria(); searchCriterium.CountryCode(validationResult.Criteria.CountryCode()); searchCriterium.StateCode(validationResult.Criteria.StateCode()); if (!validationResult.Criteria.City().IsNullOrEmpty()) { searchCriterium.City(validationResult.Criteria.City()); } validationResult.Criteria = searchCriterium; } lookupLocationValidationVm.IsValid = validationResult.IsValid; lookupLocationValidationVm.Criteria = (lookupLocationValidationVm.IsValid ? validationResult.Criteria.MapToSearchCriteriaVm(searchType) : new SearchCriteriaVm()); lookupLocationValidationVm.Variants = (lookupLocationValidationVm.IsValid ? new List <AutocompleteVm>() : validationResult.Variants.MapToAutocompleteVmList(searchType, string.Empty)); lookupLocationValidationVm.SearchUrl = (lookupLocationValidationVm.IsValid ? MslcUrlBuilder.SearchUrl(validationResult.Criteria, searchType) : string.Empty); return(lookupLocationValidationVm); }