diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-11-14 03:26:19 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-11-14 03:26:19 +0100 |
| commit | 47004bfcf8ef72556d8227bbce7dd5c06dc73040 (patch) | |
| tree | 1d792c099b5b01a0c4ed33b2622985655f000837 /code/api | |
| parent | 76004edc90fad76a874ce4c4b51a86c5a4ec1de7 (diff) | |
| download | greatoffice-47004bfcf8ef72556d8227bbce7dd5c06dc73040.tar.xz greatoffice-47004bfcf8ef72556d8227bbce7dd5c06dc73040.zip | |
refactor: Support querying on project name
Diffstat (limited to 'code/api')
| -rw-r--r-- | code/api/src/Endpoints/V1/Projects/GetProjectsRoute.cs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/code/api/src/Endpoints/V1/Projects/GetProjectsRoute.cs b/code/api/src/Endpoints/V1/Projects/GetProjectsRoute.cs index d60f974..8fe70a6 100644 --- a/code/api/src/Endpoints/V1/Projects/GetProjectsRoute.cs +++ b/code/api/src/Endpoints/V1/Projects/GetProjectsRoute.cs @@ -13,9 +13,9 @@ public class GetProjectsRoute : RouteBaseAsync.WithRequest<GetProjectsQueryParam } [HttpGet("~/v{version:apiVersion}/projects")] - public override async Task<ActionResult<KeysetPaginationResult<GetProjectsResponseDto>>> HandleAsync(GetProjectsQueryParameters request, CancellationToken cancellationToken = default) { + public override async Task<ActionResult<KeysetPaginationResult<GetProjectsResponseDto>>> HandleAsync([FromQuery] GetProjectsQueryParameters request, CancellationToken cancellationToken = default) { var result = await _pagination.KeysetPaginateAsync( - _database.Projects.ForTenant(LoggedInUser), + _database.Projects.ForTenant(LoggedInUser).ConditionalWhere(() => request.NameQuery.HasValue(), p => p.Name.Contains(request.NameQuery)), b => b.Descending(x => x.CreatedAt), async id => await _database.Projects.FindAsync(id), query => query.Select(p => new GetProjectsResponseDto() { @@ -35,9 +35,6 @@ public class GetProjectsResponseDto public class GetProjectsQueryParameters { - [FromQuery] - public int Page { get; set; } - - [FromQuery] - public int Size { get; set; } + [FromQuery(Name = "name")] + public string NameQuery { get; set; } }
\ No newline at end of file |
