public static MailContactData ToContactData(this ContactCardDto contactCard)
        {
            var emails = new MailContactData.EmailsList <ContactInfo>();
            var phones = new MailContactData.PhoneNumgersList <ContactInfo>();

            foreach (var contact in contactCard.contacts)
            {
                switch (contact.type)
                {
                case (int)ContactInfoType.Email:
                    if (contact.isPrimary)
                    {
                        emails.Insert(0, new ContactInfo {
                            Id = contact.id, Value = contact.data, IsPrimary = contact.isPrimary
                        });
                    }
                    else
                    {
                        emails.Add(new ContactInfo {
                            Id = contact.id, Value = contact.data, IsPrimary = contact.isPrimary
                        });
                    }
                    break;

                case (int)ContactInfoType.Phone:
                    if (contact.isPrimary)
                    {
                        phones.Insert(0, new ContactInfo {
                            Id = contact.id, Value = contact.data, IsPrimary = contact.isPrimary
                        });
                    }
                    else
                    {
                        phones.Add(new ContactInfo {
                            Id = contact.id, Value = contact.data, IsPrimary = contact.isPrimary
                        });
                    }
                    break;
                }
            }

            var contactData = new MailContactData
            {
                ContactId     = contactCard.id,
                Name          = contactCard.name,
                Description   = contactCard.description,
                Emails        = emails,
                PhoneNumbers  = phones,
                Type          = contactCard.type,
                SmallFotoUrl  = String.Format("{0}HttpHandlers/contactphoto.ashx?cid={1}&ps=1", BaseAbsolutePath, contactCard.id).ToLower(),
                MediumFotoUrl = String.Format("{0}HttpHandlers/contactphoto.ashx?cid={1}&ps=2", BaseAbsolutePath, contactCard.id).ToLower()
            };

            return(contactData);
        }
        public static MailContactData ToMailContactData(this ContactCard contactCard)
        {
            var baseAbsolutePath = CommonLinkUtility.ToAbsolute(BASE_VIRTUAL_PATH).ToLower();

            var emails = new MailContactData.EmailsList <ContactInfo>();
            var phones = new MailContactData.PhoneNumgersList <ContactInfo>();

            foreach (var contact in contactCard.ContactItems)
            {
                if (contact.Type == (int)ContactInfoType.Email)
                {
                    if (contact.IsPrimary)
                    {
                        emails.Insert(0,
                                      new ContactInfo {
                            Id = contact.Id, Value = contact.Data, IsPrimary = contact.IsPrimary
                        });
                    }
                    else
                    {
                        emails.Add(new ContactInfo
                        {
                            Id        = contact.Id,
                            Value     = contact.Data,
                            IsPrimary = contact.IsPrimary
                        });
                    }
                }
                else if (contact.Type == (int)ContactInfoType.Phone)
                {
                    if (contact.IsPrimary)
                    {
                        phones.Insert(0,
                                      new ContactInfo {
                            Id = contact.Id, Value = contact.Data, IsPrimary = contact.IsPrimary
                        });
                    }
                    else
                    {
                        phones.Add(new ContactInfo
                        {
                            Id        = contact.Id,
                            Value     = contact.Data,
                            IsPrimary = contact.IsPrimary
                        });
                    }
                }
            }

            var contactData = new MailContactData
            {
                ContactId    = contactCard.ContactInfo.Id,
                Name         = contactCard.ContactInfo.ContactName,
                Description  = contactCard.ContactInfo.Description,
                Emails       = emails,
                PhoneNumbers = phones,
                Type         = (int)contactCard.ContactInfo.Type,
                SmallFotoUrl =
                    string.Format("{0}HttpHandlers/contactphoto.ashx?cid={1}&ps=1", baseAbsolutePath, contactCard.ContactInfo.Id)
                    .ToLower(),
                MediumFotoUrl =
                    string.Format("{0}HttpHandlers/contactphoto.ashx?cid={1}&ps=2", baseAbsolutePath, contactCard.ContactInfo.Id)
                    .ToLower()
            };

            return(contactData);
        }