Beispiel #1
0
        private bool TheSameStreet(string street)
        {
            if (string.IsNullOrWhiteSpace(street))
            {
                return(false);
            }

            var sameStreet = Street.Contains(street) || street.Contains(Street);

            return(sameStreet);
        }
Beispiel #2
0
        private string ConcatAddressComponents(bool useBuildingName = false)
        {
            var addressSections = IsZipCodeReversedFormat()
                                ? new[] { FirstSectionOfDisplayAddress, LastSectionOfDisplayAddress, State.ToSafeString() }.Where(x => x.HasValueTrimmed()).ToArray()
                                : new[] { FirstSectionOfDisplayAddress, City.ToSafeString(), LastSectionOfDisplayAddress }.Where(x => x.HasValueTrimmed()).ToArray();

            if (FirstSectionOfDisplayAddress.HasValueTrimmed() &&
                LastSectionOfDisplayAddress.HasValueTrimmed() &&
                FirstSectionOfDisplayAddress.Contains(LastSectionOfDisplayAddress))
            {
                // special case where we only had a FullAddress that we added value to but we don't want to redo the loop again
                return(FirstSectionOfDisplayAddress);
            }

            // should return ("StreetNumber Street" or "Street StreetNumber" or "FullAddress"), ("City", "State" "ZipCode" or "ZipCode" "City", "State")
            var address = string.Join(", ", addressSections);

            if (useBuildingName && BuildingName.HasValueTrimmed())
            {
                address = BuildingName + " - " + address;
            }

            // Check if full address is really a full address
            // If it doesn't contain the city, then we overwrite FullAddress with the value of DisplayAddress
            // We also check that the street doesn't contain the city, ie: "11000 Garden Grove Blvd, Garden Grove, CA 92843"
            if (FullAddress.HasValueTrimmed())
            {
                if (!FullAddress.Contains(City.ToSafeString()))
                {
                    FullAddress = address;
                }
                else
                {
                    if (Street.HasValueTrimmed() && Street.Contains(City.ToSafeString()))
                    {
                        FullAddress = address;
                    }
                }
            }

            return(address);
        }