Exemplo n.º 1
0
        private Contact ConvertToDbo(ContactModel model)
        {
            var contact = new Contact
                    {
                        Id = model.Id ?? 0,
                        FirstName = model.FirstName,
                        SecondName = model.SecondName,
                        Email = model.Email,
                        PhoneNumbers = model.PhoneNumbers.Select(ConvertToDbo).ToList()
                    };

            foreach(var phoneNumber in contact.PhoneNumbers)
            {
                phoneNumber.Contact = contact;
            }

            return contact;
        }
Exemplo n.º 2
0
 private ContactModel ConvertToModel(Contact dbo)
 {
     return new ContactModel
     {
         Id = dbo.Id,
         FirstName = dbo.FirstName,
         SecondName = dbo.SecondName,
         Email = dbo.Email,
         PhoneNumbers = dbo.PhoneNumbers.Select(ConvertToModel).ToList()
     };
 }