private void NameInMessyAddressContainsSpace(CleanAddressInformation clean)
        {
            //stoped here
            var splitname = item.Name.Split(' ');

            clean.FirstName = splitname[0];
            clean.LastName  = splitname[1];
        }
Beispiel #2
0
        public List <CleanAddressInformation> CleanAddresses(
            List <MessyAddressInformation> messyAddresses)
        {
            var cleanAddresses = new List <CleanAddressInformation>();

            foreach (var messyAddress in messyAddresses)
            {
                var clean = new CleanAddressInformation();

                //if (messyAddress.Name != null)
                //{
                var splitName = messyAddress.Name?.Split(' ');
                //    if (splitName.Length == 2)
                //    {
                //        clean.FirstName = splitName[0];
                //        clean.LastName = splitName[1];
                //    }
                //    else if (splitName.Length == 1)
                //    {
                //        if (splitName[0].Length == 0)
                //        {
                //            clean.FirstName = "N/A";
                //            clean.LastName = "N/A";
                //        }
                //        else
                //        {
                //            clean.FirstName = splitName[0];
                //            clean.LastName = "N/A";
                //        }
                //    }
                //}

                messyAddress.Name != null ? clean.FirstName = splitName[0] : clean.FirstName = "N/A";

                if (messyAddress.Address != null)
                {
                    var splitAddress = messyAddress.Address.Split(',');
                    if (splitAddress.Length == 4)
                    {
                        clean.StreetAddress = splitAddress[0];
                        clean.City          = splitAddress[1].Trim();
                        clean.State         = splitAddress[2].Trim();
                        clean.ZipCode       = splitAddress[3].Trim();
                    }
                    else
                    {
                        clean.StreetAddress = "N/A";
                        clean.City          = "N/A";
                        clean.State         = "N/A";
                        clean.ZipCode       = "N/A";
                    }
                }

                cleanAddresses.Add(clean);
            }

            return(cleanAddresses);
        }
        public List <CleanAddressInformation> CleanAddresses(
            List <MessyAddressInformation> messyAddresses)
        {
            //creates a new CleanList
            List <CleanAddressInformation> cleanlist = new List <CleanAddressInformation>();


            foreach (var item in messyAddresses)
            {
                var clean = new CleanAddressInformation();

                if (item.Name != null)
                {
                    if (item.Name.Contains(' '))
                    {
                        //stoped here 4/22(date)
                        NameInMessyAddressContainsSpace(clean);
                    }
                    else
                    {
                        if (item.Name.Length > 0)
                        {
                            clean.FirstName = item.Name;
                            clean.LastName  = "N/A";
                        }
                        else
                        {
                            clean.FirstName = "N/A";
                            clean.LastName  = "N/A";
                        }
                    }
                }

                if (item.Address != null)
                {
                    if (item.Address.Contains(','))
                    {
                        var addressToSplit = item.Address.Split(',');
                        clean.StreetAddres = addressToSplit[0];
                        clean.City         = addressToSplit[1].Trim();
                        clean.State        = addressToSplit[2].Trim();
                        clean.ZipCode      = addressToSplit[3].Trim();

                        //if (clean.City.Length < 1 && clean.State.Length < 1 && clean.ZipCode.Length < 1)
                        //{
                        //    clean.StreetAddres = "N/A";
                        //}
                    }
                    else
                    {
                        clean.StreetAddres = "N/A";
                        clean.City         = "N/A";
                        clean.State        = "N/A";
                        clean.ZipCode      = "N/A";
                    }
                }

                cleanlist.Add(clean);
            }

            return(cleanlist);
        }