public async Task <PaginationOutput <JobDto> > GetListAsync(QueryJobInput input) { CancellationToken.ThrowIfCancellationRequested(); if (input == null) { throw new ArgumentNullException(nameof(input)); } var query = from a in _context.Jobs select new JobDto() { Id = a.Id, Title = a.Title, Enable = a.Enable, AgeRange = a.AgeRange, SalaryRange = a.SalaryRange, GenderRange = a.GenderRange, CreationTime = a.CreationTime }; var totalCount = await query.CountAsync(CancellationToken); var totalSize = (int)Math.Ceiling(totalCount / (decimal)input.PageSize); var jobs = await query.OrderByDescending(o => o.CreationTime) .Skip((input.PageIndex - 1) * input.PageSize) .Take(input.PageSize).ToListAsync(CancellationToken); return(new PaginationOutput <JobDto>(totalSize, jobs)); }
public async Task <PaginationOutput <JobDto> > GetListAsync(QueryJobInput input) { var query = from a in _context.Jobs select new JobDto() { Id = a.Id, Title = a.Title, Enable = a.Enable, AgeRange = a.AgeRange, SalaryRange = a.SalaryRange, GenderRange = a.GenderRange, CreationTime = a.CreationTime }; var totalCount = await query.CountAsync(); var totalSize = (int)Math.Ceiling(totalCount / (decimal)input.PageSize); var jobs = await query.OrderByDescending(o => o.CreationTime) .Skip((input.PageIndex - 1) * input.PageSize) .Take(input.PageSize).ToListAsync(); return(new PaginationOutput <JobDto>(totalSize, jobs)); }
public async Task <IActionResult> List(QueryJobInput input) { var output = await _jobQuerier.GetListAsync(input); return(View(new PaginationModel <JobDto>(output, input))); }