Exemplo n.º 1
0
        public ContactModel Create(Contact contact)
        {
            var result = new ContactModel
            {
                Name = contact.FirstName,
                Id = contact.Id,
                ContactGroupId = contact.ContactGroupId,
                Phones = contact.ContactPhones.Select((c => Create(c)))
            };

            return result;
        }
Exemplo n.º 2
0
        public Contact Parse(ContactModel model, int contactGroupId)
        {
            try
            {
                var contact = new Contact
                {
                    FirstName = model.Name,
                    ContactGroupId = contactGroupId
                };

                foreach (var contactPhoneModel in model.Phones)
                {
                    contact.ContactPhones.Add(Parse(contactPhoneModel));
                }

                ////Below code is an example of how to get ID for url's pass in to the model
                //var uri = new Uri(model.URL);
                //var notificationId = int.Parse(uri.Segments.Last());

                return contact;
            }
            catch (Exception)
            {
                return null;
            }
        }