I have a JobsController that has a GetJobs method as follows:
[HttpGet]
... Task<IActionResult> GetJobs([FromQuery] Pagination urlQuery)
... return await _dbContext.Jobs
.AsNoTracking
.Where(x => x.BankId == user.BankId)
.Skip(urlQuery.Limit *(urlQuery.Offset -1))
.Take(urlQuery.Limit)
.ToListAsync()
I have successfully implemented paging functionality: .../jobs?limit=25&offset=1
I tried creating a filter class
...
public int BankId {get; set;}
public bool Archived {get; set;}
...
public bool HaveFilter => !string.IsNullOrEmpty(BankId.ToString()) ||
!string.IsNullOrEmpty(Archived.ToString())
But then it gets messy when trying to use this alongside Pagination.
What would be the best way to implement server-side filtering so that I can use something like .../jobs?limit=25&offset=1&bankId=3&archived=true ?