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 GroupDto GetGroup(int UserId, int id) { var context = new AddressBookContext(); var user = context.GetUser(UserId); if (user != null) { var group = user.Groups.ToList().Find(s => s.Id == id); if (group != null) { return(GroupDto.Get(group)); } } return(null); }
public static SubscriberDto Get(Subscriber subscriber) { return(new SubscriberDto() { Id = subscriber.Id, FirstName = subscriber.FirstName, MiddleName = subscriber.MiddleName, LastName = subscriber.LastName, DateOfBirth = subscriber.DateOfBirth, Photo = subscriber.Photo, Sex = subscriber.Sex, Mail = subscriber.Mail, Addresses = (IEnumerable <Address>)subscriber.Addresses.Select(a => AddressDto.Get(a)).ToList(), Groups = (IEnumerable <Group>)subscriber.Groups.Select(g => GroupDto.Get(g)).ToList(), Phones = (IEnumerable <Phone>)subscriber.Phones.Select(p => PhoneDto.Get(p)).ToList() }); }