public static IAddress ToAddress(this SearchResultItem result)
        {
            if (result != null)
            {
                var Address = new Models.Address();

                string FormattedAddress;

                FormattedAddress = result.FieldItems.TryGetValue("FULL_ADDRESS");

                var Index = Math.Max(0, FormattedAddress.IndexOf(result.FieldItems.TryGetValue("STREET") + ","));

                Address.Uprn = long.Parse(result.FieldItems.TryGetValue("UPRN") ?? null);
                //Address.Usrn = long.Parse(result.FieldItems.TryGetValue("USRN") ?? null);
                //Address.Organisation = result.FieldItems.TryGetValue("ORGANISATION");
                Address.Property = (!String.IsNullOrWhiteSpace(FormattedAddress) ? FormattedAddress.Substring(0, Index) : String.Empty).Trim().TrimEnd(',');
                Address.Street   = result.FieldItems.TryGetValue("STREET");
                Address.Locality = result.FieldItems.TryGetValue("LOCALITY");
                Address.Town     = result.FieldItems.TryGetValue("TOWN");
                Address.Area     = result.FieldItems.TryGetValue("POSTTOWN");
                Address.PostCode = result.FieldItems.TryGetValue("POSTCODE");

                return(Address);
            }
            return(null);
        }
Beispiel #2
0
        public override int GetHashCode()
        {
            int hash = 0;

            if (!string.IsNullOrWhiteSpace(AddressLine))
            {
                hash ^= AddressLine.GetHashCode();
            }

            if (!string.IsNullOrWhiteSpace(AdminDistrict))
            {
                hash ^= AdminDistrict.GetHashCode();
            }

            if (!string.IsNullOrWhiteSpace(AdminDistrict2))
            {
                hash ^= AdminDistrict2.GetHashCode();
            }

            if (!string.IsNullOrWhiteSpace(CountryRegion))
            {
                hash ^= CountryRegion.GetHashCode();
            }

            if (!string.IsNullOrWhiteSpace(FormattedAddress))
            {
                hash ^= FormattedAddress.GetHashCode();
            }

            if (!string.IsNullOrWhiteSpace(Locality))
            {
                hash ^= Locality.GetHashCode();
            }

            if (!string.IsNullOrWhiteSpace(PostalCode))
            {
                hash ^= PostalCode.GetHashCode();
            }

            if (!string.IsNullOrWhiteSpace(PostalTown))
            {
                hash ^= PostalTown.GetHashCode();
            }

            if (!string.IsNullOrWhiteSpace(Landmark))
            {
                hash ^= Landmark.GetHashCode();
            }

            if (!string.IsNullOrWhiteSpace(Neighborhood))
            {
                hash ^= Neighborhood.GetHashCode();
            }

            return(hash);
        }
Beispiel #3
0
    /// <summary>
    /// Return a formatted address from the supplied search.
    /// </summary>
    public string[] RefinePostcode(string p)
    {
        // Append the postcode to our address to speed up and improve searches.
        string       search = p + "," + Postcode;
        SearchResult result = this.searchService.Search("GBR",
                                                        postCode,
                                                        PromptSet.Types.OneLine,
                                                        "Database layout");

        if (result.Picklist.Items.Length > 0)
        {
        }
        else
        {
            // What is your workflow if an address is not found?
        }
        string           moniker          = this.GetMoniker(search);
        FormattedAddress formattedAddress = this.searchService.GetFormattedAddress(moniker, "Database Layout");

        return(new string[] { formattedAddress.AddressLines[0].Line, formattedAddress.AddressLines[1].Line, formattedAddress.AddressLines[2].Line, formattedAddress.AddressLines[3].Line, formattedAddress.AddressLines[4].Line, formattedAddress.AddressLines[5].Line, formattedAddress.AddressLines[6].Line });
    }
        /// <summary>
        /// Converts a QAS address object to an equivalent
        /// <see cref="FormattedAddress"/> object.
        /// </summary>
        /// <param name="qaAddress">The QAS address object to convert.</param>
        /// <param name="formattedAddress">The <see cref="FormattedAddress"/> to populate.</param>
        private void Convert(QAAddressType qaAddress, FormattedAddress formattedAddress)
        {
            formattedAddress.AddressLine1 = qaAddress.AddressLine[0].Line;
            formattedAddress.AddressLine2 = qaAddress.AddressLine[1].Line;

            string[] parts = qaAddress.AddressLine[3].Line.Split(' ');
            parts = parts.Where(p => p != string.Empty).ToArray();
            formattedAddress.Suburb = parts[0];
            formattedAddress.State = parts[1];
            formattedAddress.Postcode = parts[2];
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AddressRetrieveResult"/> class.
 /// </summary>
 /// <param name="success">The success flag.</param>
 /// <param name="address">The formatted address.</param>
 public AddressRetrieveResult(bool success, FormattedAddress address)
 {
     this.Success = success;
     this.Address = address;
 }