public async Task <IActionResult> GetEmployees([FromQuery] EmpParms parms) { PagedList <Employee> employees = await _repo.GetEmployees(parms); Response.AddPagination(employees.CurrentPage, employees.PageSize, employees.TotalCount, employees.TotalPage); var paged = new PagedClass <PagedList <Employee> > { Pagination = new PaginationHeader(employees.CurrentPage, employees.PageSize, employees.TotalCount, employees.TotalPage), Result = employees }; return(Ok(paged)); }
public async Task <PagedList <Employee> > GetEmployees(EmpParms parms) { var employees = _context.Employees.Where(i => (!string.IsNullOrEmpty(parms.Name)? i.Name.Contains(parms.Name):true) && (!string.IsNullOrEmpty(parms.Phone)? i.Mobile.Contains(parms.Phone):true)); return(await PagedList <Employee> .CreatAsync(employees, parms.PageNumber, parms.PageSize)); }