Ejemplo n.º 1
0
 public async Task <Response <PageModel <UserWithCompaniesDTO> > > GetUsersPage([FromQuery] PageModel model, [FromQuery] UserFilterAdminDTO filter)
 {
     return(await _handler.GetUsersPage(model, filter));
 }
Ejemplo n.º 2
0
        public async Task <Response <PageModel <UserWithCompaniesDTO> > > GetUsersPage(PageModel model, UserFilterAdminDTO filter)
        {
            var result = await _provider.GetUsersPage(model, filter);

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <Response <PageModel <UserWithCompaniesDTO> > > GetUsersPage(PageModel model, UserFilterAdminDTO filter)
        {
            var mappedFilter    = _mapper.Map <UserFilterModel>(filter);
            var usersEntityPage = await _usersRepository.GetPage(model, mappedFilter);

            var usersDtoPage = _mapper.Map <PageModel <UserWithCompaniesDTO> >(usersEntityPage);

            var usersCompaniesEntityList = (await _companiesUsersRepository.GetCompaniesByUsers(
                                                usersDtoPage.Items.Select(x => x.User.Id))).ToList();

            foreach (var user in usersDtoPage.Items)
            {
                user.Companies = _mapper.Map <IEnumerable <CompanyWithUserRoleDTO> >(
                    usersCompaniesEntityList.Where(x => x.UserId == user.User.Id));
            }

            return(new Response <PageModel <UserWithCompaniesDTO> >
            {
                Data = usersDtoPage
            });
        }