public static List <PAFAddress> GetAddressList(Locality locality, ThoroughFare thoroughFare, IEnumerable <DeliveryPoint> deliveryPoints) { var addressList = new List <PAFAddress>(); foreach (var item in deliveryPoints) { string addresses = FormatAddress1(item) + FormatAddress2(thoroughFare, item) + FormatAddress3(locality); PAFAddress addressData = GetAddress(addresses); addressData.Town = locality.PostTown; addressData.PostCode = locality.Outcode.Trim().PadRight(locality.Outcode.Trim().Length + 1) + locality.Incode.Trim(); addressList.Add(addressData); } var alphanum = new AlphanumComparator(); addressList.Sort(alphanum); return(addressList); }
public ThoroughFare GeThoroughFare(Locality locality) { try { ThoroughFare thoroughFare = null; if (!locality.IsWelsh) { thoroughFare = GetThoroughFare(locality.Outcode, locality.Incode); } else { var welshThoroughFare = GetWelshThoroughFare(locality.Outcode, locality.Incode); if (welshThoroughFare != null) { thoroughFare = new ThoroughFare { ThoroughFareID = welshThoroughFare.WelshThoroughFareID, Outcode = welshThoroughFare.Outcode, Incode = welshThoroughFare.Incode, PostCodeType = welshThoroughFare.PostCodeType, Sequence = welshThoroughFare.Sequence, ThoroughFareName = welshThoroughFare.ThoroughFareName, ThoroughFareDescriptor = welshThoroughFare.ThoroughFareDescriptor, DepThoroughFareName = welshThoroughFare.DepThoroughFareName, DepThoroughFareDescriptor = welshThoroughFare.ThoroughFareDescriptor, ThoroughFareNameTidy = welshThoroughFare.ThoroughFareNameTidy, DepThoroughFareNameTidy = welshThoroughFare.DepThoroughFareNameTidy }; } } return(thoroughFare); } catch (Exception e) { throw; } }
private static string FormatAddress2(ThoroughFare thoroughFare, DeliveryPoint deliveryPoint) { return(string.Format("{0}{1}{2}{3}{4}", ValidateNumeric(deliveryPoint.BuildingName) ? deliveryPoint.BuildingName.Trim().PadRight(deliveryPoint.BuildingName.Trim().Length + 1, ' ') : string.Empty, deliveryPoint.BuildingNumber > 0 ? deliveryPoint.BuildingNumber.ToString().Trim().PadRight(deliveryPoint.BuildingNumber.ToString().Trim().Length + 1, ' ') : string.Empty, !string.IsNullOrWhiteSpace(thoroughFare.DepThoroughFareName) ? thoroughFare.DepThoroughFareName.Trim().PadRight(thoroughFare.DepThoroughFareName.Trim().Length + 1, ' ') : string.Empty, !string.IsNullOrWhiteSpace(thoroughFare.DepThoroughFareDescriptor) ? thoroughFare.DepThoroughFareDescriptor + "|" : string.Empty, !string.IsNullOrWhiteSpace(thoroughFare.ThoroughFareDescriptor) ? thoroughFare.ThoroughFareName.Trim().PadRight(thoroughFare.ThoroughFareName.Trim().Length + 1, ' ') + thoroughFare.ThoroughFareDescriptor + "|" : !string.IsNullOrWhiteSpace(thoroughFare.ThoroughFareName) ? thoroughFare.ThoroughFareName.Trim().PadRight(thoroughFare.ThoroughFareName.Trim().Length + 1, ' ') + "|" : string.Empty )); }