public async Task <ActionResult <AbonentDto> > GetAbonent(int userId, int id)
        {
            var user = _userService.GetUser(userId);

            if (user != null)
            {
                var abonent = _abonentService.GetAbonent(user, id);
                if (abonent != null)
                {
                    return(new AbonentDto()
                    {
                        Id = abonent.Id,
                        UserId = abonent.UserId,
                        FirstName = abonent.FirstName,
                        MiddleName = abonent.MiddleName,
                        LastName = abonent.LastName,
                        Sex = abonent.Sex,
                        DateOfBirth = abonent.DateOfBirth,
                        Photo = abonent.Photo,
                        Mail = abonent.Mail
                    });
                }
                return(BadRequest("User -> Abonent not found"));
            }
            return(BadRequest("User not found"));
        }
Ejemplo 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);
        }