public async Task <JsonResult> GetPagedData(PagedFileResultRequestDto input) { var p = GetPagedInput(); input.MaxResultCount = p.MaxResultCount; input.Sorting = p.Sorting; input.SkipCount = p.SkipCount; //input.DepotId = depotId; //input.PostId = postId; var output = await _fieldAppService.SearchFilePagedResult(input); return(Json(new { total = output.TotalCount, rows = output.Items })); }
public async Task <PagedResultDto <WorkerFileDto> > SearchFilePagedResult(PagedFileResultRequestDto input) { var query = _workerFileRepository.GetAllIncluding(x => x.Worker, x => x.Worker.Depot, x => x.Worker.Post) .WhereIf(input.DepotId.HasValue, x => x.Worker.DepotId == input.DepotId.Value) .WhereIf(input.PostId.HasValue, x => x.Worker.DepotId == input.PostId.Value) .WhereIf(input.Status != null, x => x.Status == input.Status); var totalCount = await AsyncQueryableExecuter.CountAsync(query); if (!string.IsNullOrWhiteSpace(input.Sorting)) { query = query.OrderBy(input.Sorting); // Applying Sorting } query = query.Skip(input.SkipCount).Take(input.MaxResultCount); // Applying Paging var entities = await AsyncQueryableExecuter.ToListAsync(query); return(new PagedResultDto <WorkerFileDto>( totalCount, ObjectMapper.Map <List <WorkerFileDto> >(entities) )); }