public static UserDto Get(User user)
 {
     return(new UserDto()
     {
         Id = user.Id,
         Login = user.Login,
         Password = user.Password,
         Subscriber = (IEnumerable <Subscriber>)user.Subscribers.Select(a => SubscriberDto.Get(a)).ToList(),
         GroupAddress = (IEnumerable <GroupAddress>)user.GroupAddresses.Select(a => GroupAddressDto.Get(a)).ToList(),
         GroupPhone = (IEnumerable <GroupPhone>)user.GroupPhones.Select(a => GroupPhoneDto.Get(a)).ToList(),
         Group = (IEnumerable <Group>)user.Groups.Select(a => GroupDto.Get(a)).ToList()
     });
 }
        public SubscriberDto GetSubscriber(int UserId, int id)
        {
            var context = new AddressBookContext();
            var user    = context.GetUser(UserId);

            if (user != null)
            {
                var subscriber = user.Subscribers.ToList().Find(s => s.Id == id);
                if (subscriber != null)
                {
                    return(SubscriberDto.Get(subscriber));
                }
            }
            return(null);
        }