Ejemplo n.º 1
0
        public Phone viewModelToPhone(PhoneVM model)
        {
            Phone phone = new Phone
            {
                Id = model.Id,
                PhoneType = model.PhoneType,
                PhoneNumber = model.PhoneNumber,
                DateCreated = model.DateCreated,
                DateModified = model.DateModified
            };

            return phone;
        }
Ejemplo n.º 2
0
        public PhoneVM phoneToViewModel(Phone phone)
        {
            PhoneVM model = new PhoneVM
            {
                Id = phone.Id,
                PhoneType = phone.PhoneType,
                PhoneNumber = phone.PhoneNumber,
                DateCreated = phone.DateCreated,
                DateModified = phone.DateModified
            };

            return model;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets list of phone numbers associated with a specific contact.
        /// </summary>
        /// <param name="contactId"></param>
        /// <returns></returns>
        private ICollection<PhoneVM> GetPhoneNumbers(int contactId)
        {
            PhoneVM vm = new PhoneVM();
            List<Phone> phoneNumbers = db.PhoneNumbers.Where(c => c.Contact.Id == contactId).ToList();
            ICollection<PhoneVM> phoneList = new List<PhoneVM>();

            foreach (Phone phone in phoneNumbers)
            {
                phoneList.Add(vm.phoneToViewModel(phone));
            }

            return phoneList;
        }