public async Task <PagingResult <TimesheetDto> > GetAllAsync(int employeeId, int pageIndex, int pageSize, string search) { try { Expression <Func <Timesheet, bool> > filter = x => x.EmployeeId == employeeId; IOrderedQueryable <Timesheet> OrderBy(IQueryable <Timesheet> x) { return(x.OrderByDescending(y => y.Date)); } IIncludableQueryable <Timesheet, object> Includes(IQueryable <Timesheet> x) { return(x.Include(y => y.Employee).Include(y => y.Project)); } int skip = (pageIndex - 1) * pageSize; int totalData = await _timesheetRepository.CountAsync(filter); List <Timesheet> timesheets = await _timesheetRepository.GetAllAsync(filter, Includes, OrderBy, skip, pageSize, true); return(new PagingResult <TimesheetDto> { Data = timesheets.Select(TimesheetMapper.Map).ToList(), TotalCount = totalData }); } catch (Exception ex) { _logger.LogError(ex, "Error when EmployeeService.GetAllAsync"); throw; } }