Example #1
0
        public static CDM CprToCdm(CPR cpr)
        {
            CprAddress cprAddress = splitCprAddress(cpr.Address1);

            CDM cdm = new CDM()
            {
                EuccidNo      = cpr.EuccidNo,
                ChristianName = cpr.FirstName,
                FamilyName    = cpr.Surname,
                Gender        = cpr.Gender,
                Street        = cprAddress.street,
                HouseNo       = cprAddress.houseNo,
                ApartmentNo   = cprAddress.apartmentNo,
                //County = "",
                PostalCode = cpr.PostalCode,
                City       = cpr.City,
                //BirthCountry = "",
                CountryOfResidence = "Denmark"
            };

            return(cdm);
        }
Example #2
0
        public static CprAddress splitCprAddress(string address)
        {
            CprAddress cprAddress = new CprAddress();

            cprAddress.street = new string(address
                                           .TakeWhile(c => !char.IsDigit(c))
                                           .ToArray())
                                .Trim();

            cprAddress.houseNo = new string(address
                                            .SkipWhile(c => !char.IsDigit(c))
                                            .TakeWhile(c => c != ',')
                                            .ToArray());

            cprAddress.apartmentNo = new string(address
                                                .SkipWhile(c => !char.IsDigit(c))
                                                .SkipWhile(c => c != ',')
                                                .SkipWhile(c => c == ',')
                                                .TakeWhile(c => true)
                                                .ToArray())
                                     .Trim();

            return(cprAddress);
        }