示例#1
0
 public async Task <Response <PageModel <CompanyDetailAdminDTO> > > GetCompaniesPage([FromQuery] PageModel model, [FromQuery] CompanyFilterAdminDTO filter)
 {
     return(await _handler.GetCompanyPage(model, filter));
 }
示例#2
0
        public async Task <Response <PageModel <CompanyDetailAdminDTO> > > GetCompanyPage(PageModel model, CompanyFilterAdminDTO filter)
        {
            var result = await _provider.GetCompanyPage(model, filter);

            return(result);
        }
示例#3
0
        public async Task <Response <PageModel <CompanyDetailAdminDTO> > > GetCompanyPage(PageModel model, CompanyFilterAdminDTO filter)
        {
            var mappedFilter        = _mapper.Map <CompanyFilterModel>(filter);
            var companiesEntityPage = await _companiesRepository.GetCompanies(model, mappedFilter);

            var companyDtoPage = _mapper.Map <PageModel <CompanyDetailAdminDTO> >(companiesEntityPage);

            var usersCompaniesEntityList = (await _companiesUsersRepository.GetUsersByCompanies(
                                                companyDtoPage.Items.Select(x => x.Id))).ToList();

            foreach (var company in companyDtoPage.Items)
            {
                var companyUsers = usersCompaniesEntityList.Where(x => x.CompanyId == company.Id).ToList();
                company.UsersCount = companyUsers.Count(x => x.User.Status != UserStatus.Active);
                company.Admins     = _mapper.Map <IEnumerable <UserWithRoleDTO> >(companyUsers.Where(x => x.Status != MembershipStatus.Member));
            }

            return(new Response <PageModel <CompanyDetailAdminDTO> >
            {
                Data = companyDtoPage
            });
        }