Esempio n. 1
0
        }         // FillFromOneLine

        private void FillFromTwoLines(CustomerAddressModel filled)
        {
            filled.HouseNumber = Regex.Match(Line1, "\\d*").Value;

            if (!string.IsNullOrWhiteSpace(filled.HouseNumber))
            {
                var line1 = Line1.Split(' ');
                filled.HouseNumber = line1[0];
                filled.Address1    = string.Join(" ", line1.Skip(1));
                filled.Address2    = Line2;
                return;
            }             // if

            string uLine1 = Line1.ToUpper();

            if (uLine1.StartsWith("APARTMENT") || uLine1.StartsWith("FLAT"))
            {
                filled.FlatOrApartmentNumber = Line1;
                filled.HouseNumber           = Regex.Match(Line2, "\\d*").Value;

                if (!string.IsNullOrWhiteSpace(filled.HouseNumber))
                {
                    var line2 = Line2.Split(' ');
                    filled.HouseNumber = line2[0];
                    filled.Address1    = string.Join(" ", line2.Skip(1));
                }
                else
                {
                    filled.Address1 = Line2;
                }
            }
            else
            {
                filled.HouseNumber = Regex.Match(Line2, "\\d*").Value;
                filled.HouseName   = Line1;

                if (!string.IsNullOrWhiteSpace(filled.HouseNumber))
                {
                    var line2 = Line2.Split(' ');
                    filled.HouseNumber = line2[0];
                    filled.Address1    = string.Join(" ", line2.Skip(1));
                }
                else
                {
                    filled.Address1 = Line2;
                }
            }     // if
        }         // FillFromTwoLines
Esempio n. 2
0
        }         // FillDetails

        private void FillFromOneLine(CustomerAddressModel filled)
        {
            filled.HouseNumber = Regex.Match(Line1, "\\d*").Value;

            if (!string.IsNullOrWhiteSpace(filled.HouseNumber))
            {
                var line1 = Line1.Split(' ');
                filled.HouseNumber = line1[0];
                filled.Address1    = string.Join(" ", line1.Skip(1));
            }
            else if (Line1.ToUpper().StartsWith("PO BOX"))
            {
                filled.POBox = Line1;
            }
            else
            {
                filled.HouseName = Line1;
            }
        }         // FillFromOneLine
Esempio n. 3
0
        }         // ToString

        public void FillDetails()
        {
            var filled = new CustomerAddressModel {
                FlatOrApartmentNumber = string.Empty,
                HouseName             = string.Empty,
                HouseNumber           = string.Empty,
                Address1 = string.Empty,
                Address2 = string.Empty,
                POBox    = string.Empty,
            };

            if (!string.IsNullOrWhiteSpace(Line1))
            {
                if (!string.IsNullOrWhiteSpace(Line2))
                {
                    if (!string.IsNullOrWhiteSpace(Line3))
                    {
                        FillFromThreeLines(filled);
                    }
                    else
                    {
                        FillFromTwoLines(filled);
                    }
                }
                else
                {
                    FillFromOneLine(filled);
                }
            }             // if

            Address1              = filled.Address1;
            Address2              = filled.Address2;
            HouseName             = filled.HouseName;
            HouseNumber           = filled.HouseNumber;
            FlatOrApartmentNumber = filled.FlatOrApartmentNumber;
            POBox = filled.POBox;
        }         // FillDetails
Esempio n. 4
0
        }         // FillFromTwoLines

        private void FillFromThreeLines(CustomerAddressModel filled)
        {
            string uLine1 = Line1.ToUpper();

            if (uLine1.StartsWith("APARTMENT") || uLine1.StartsWith("FLAT"))
            {
                filled.FlatOrApartmentNumber = Line1;
                filled.HouseNumber           = Regex.Match(Line2, "\\d*").Value;

                if (!string.IsNullOrWhiteSpace(filled.HouseNumber))
                {
                    string[] line2 = Line2.Split(' ');
                    filled.HouseNumber = line2[0];
                    filled.Address1    = string.Join(" ", line2.Skip(1));
                    filled.Address2    = Line3;
                }
                else
                {
                    filled.HouseNumber = Regex.Match(Line3, "\\d*").Value;

                    if (!string.IsNullOrWhiteSpace(filled.HouseNumber))
                    {
                        string[] line3 = Line3.Split(' ');
                        filled.HouseNumber = line3[0];
                        filled.Address1    = string.Join(" ", line3.Skip(1));
                    }
                    else
                    {
                        filled.Address1 = Line3;
                    }

                    filled.HouseName = Line2;
                }                 // if

                return;
            }             // if

            bool neitherUnitNorBlock =
                !uLine1.Contains("UNIT") &&
                !uLine1.Contains("BLOCK") &&
                Regex.Match(Line1, "^\\d[0-9a-zA-Z ]*$").Success;

            if (neitherUnitNorBlock)
            {
                filled.HouseNumber = Regex.Match(Line1, "\\d*").Value;

                if (string.IsNullOrWhiteSpace(filled.HouseNumber))
                {
                    return;
                }

                var line1 = Line1.Split(' ');
                filled.HouseNumber = line1[0];
                filled.Address1    = string.Join(" ", line1.Skip(1));
                filled.Address2    = Line2;
            }
            else
            {
                filled.HouseName = Line1;
                filled.Address1  = Line2;
                filled.Address2  = Line3;
            } // if
        }     // FillFromThreeLines