コード例 #1
0
        public async Task <PagedResult <CompanyDto> > GetCompaniesAsync(CompanyQueryParamsDto queryParams)
        {
            var userId    = this.GetCurrentUserId();
            var companies = await _companyDataService
                            .GetCompaniesByUserAsync(userId, queryParams);

            var result = companies.Project <Company, CompanyDto>(_mapper.ConfigurationProvider);

            return(result);
        }
コード例 #2
0
        public async Task <PagedResult <Company> > GetCompaniesByUserAsync(int userId, CompanyQueryParamsDto queryParams)
        {
            var companiesQuery = _dbContext.Companies
                                 .Where(c => c.UserId == userId);

            if (!string.IsNullOrWhiteSpace(queryParams.FilterText))
            {
                companiesQuery = companiesQuery.Where(c => c.Name.Contains(queryParams.FilterText));
            }

            return(await companiesQuery
                   .AsNoTracking()
                   .GetPagedAsync(queryParams.PageNumber, queryParams.PageSize));
        }