public async Task <ActionResult <IEnumerable <GroupAddressDto> > > GetGroupAddress(int userId)
        {
            var user = _userService.GetUser(userId);
            List <GroupAddressDto> item = user.GroupAddresses.Select(u => new GroupAddressDto()
            {
                Id = u.Id, UserId = u.UserId, Name = u.Name
            }).ToList();

            return(item);
        }
Esempio n. 2
0
        public async Task <ActionResult <IEnumerable <PhoneDto> > > GetPhone(int userId, int abonentId)
        {
            var             user    = _userService.GetUser(userId);
            var             abonent = _abonentService.GetAbonent(user, abonentId);
            List <PhoneDto> item    = abonent.Phones.Select(p => new PhoneDto()
            {
                Id = p.Id, AbonentId = p.AbonentId, GroupPhoneId = p.GroupPhoneId, Number = p.Number
            }).ToList();

            return(item);
        }
        public async Task <ActionResult <IEnumerable <AddressDto> > > GetAddress(int userId, int abonentId)
        {
            var user               = _userService.GetUser(userId);
            var abonent            = _abonentService.GetAbonent(user, abonentId);
            List <AddressDto> item = abonent.Addresses.Select(a => new AddressDto()
            {
                Id = a.Id, AbonentId = a.AbonentId, GroupAddressId = a.GroupAddressId, Information = a.Information
            }).ToList();

            return(item);
        }
        public async Task <ActionResult <IEnumerable <AbonentGroupDto> > > GetAbonentGroup(int userId, int abonentId)
        {
            var user    = _userService.GetUser(userId);
            var abonent = _abonentService.GetAbonent(user, abonentId);
            List <AbonentGroupDto> item = abonent.Groups.Select(ag => new AbonentGroupDto()
            {
                AbonentId = abonentId, GroupId = ag.Id
            }).ToList();

            return(item);
        }
Esempio n. 5
0
        public async Task <ActionResult <UserDto> > GetUser(int id)
        {
            var user = _usersService.GetUser(id);

            if (user != null)
            {
                return(new UserDto()
                {
                    Id = user.Id,
                    Login = user.Login,
                    Password = user.Password
                });
            }
            return(BadRequest("User not found"));
        }
        public async Task <ActionResult <IEnumerable <AbonentDto> > > GetAbonent(int userId)
        {
            var user = _userService.GetUser(userId);
            List <AbonentDto> item = user.Abonents.Select(u => new AbonentDto()
            {
                Id          = u.Id,
                UserId      = u.UserId,
                FirstName   = u.FirstName,
                MiddleName  = u.MiddleName,
                LastName    = u.LastName,
                Sex         = u.Sex,
                DateOfBirth = u.DateOfBirth,
                Photo       = u.Photo,
                Mail        = u.Mail
            }).ToList();

            return(item);
        }