Esempio n. 1
0
        public static void MapTo(this IHavePhoneNumbers havePhoneNumbers, IHavePhoneNumbersEntity entity)
        {
            entity.primaryPhoneNumber       = null;
            entity.primaryPhoneNumberType   = null;
            entity.secondaryPhoneNumber     = null;
            entity.secondaryPhoneNumberType = null;
            entity.tertiaryPhoneNumber      = null;
            entity.tertiaryPhoneNumberType  = null;
            if (havePhoneNumbers == null || havePhoneNumbers.PhoneNumbers == null || havePhoneNumbers.PhoneNumbers.Count == 0)
            {
                return;
            }

            entity.primaryPhoneNumber     = havePhoneNumbers.PhoneNumbers[0].Number;
            entity.primaryPhoneNumberType = (byte?)havePhoneNumbers.PhoneNumbers[0].Type;
            if (havePhoneNumbers.PhoneNumbers.Count == 1)
            {
                return;
            }

            entity.secondaryPhoneNumber     = havePhoneNumbers.PhoneNumbers[1].Number;
            entity.secondaryPhoneNumberType = (byte?)havePhoneNumbers.PhoneNumbers[1].Type;

            if (havePhoneNumbers.PhoneNumbers.Count == 2)
            {
                return;
            }

            entity.tertiaryPhoneNumber     = havePhoneNumbers.PhoneNumbers[2].Number;
            entity.tertiaryPhoneNumberType = (byte?)havePhoneNumbers.PhoneNumbers[2].Type;
        }
Esempio n. 2
0
        public static void MapTo(this IHavePhoneNumbersEntity entity, IHavePhoneNumbers havePhoneNumbers)
        {
            if (string.IsNullOrEmpty(entity.primaryPhoneNumber) || entity.primaryPhoneNumberType == null)
            {
                havePhoneNumbers.PhoneNumbers = null;
                return;
            }

            havePhoneNumbers.PhoneNumbers = new List <PhoneNumber>
            {
                new PhoneNumber {
                    Number = entity.primaryPhoneNumber, Type = (PhoneNumberType)entity.primaryPhoneNumberType
                }
            };

            if (string.IsNullOrEmpty(entity.secondaryPhoneNumber) || entity.secondaryPhoneNumberType == null)
            {
                return;
            }
            havePhoneNumbers.PhoneNumbers.Add(new PhoneNumber {
                Number = entity.secondaryPhoneNumber, Type = (PhoneNumberType)entity.secondaryPhoneNumberType
            });

            if (string.IsNullOrEmpty(entity.tertiaryPhoneNumber) || entity.tertiaryPhoneNumberType == null)
            {
                return;
            }
            havePhoneNumbers.PhoneNumbers.Add(new PhoneNumber {
                Number = entity.tertiaryPhoneNumber, Type = (PhoneNumberType)entity.tertiaryPhoneNumberType
            });
        }