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); }
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)); }