From 47004bfcf8ef72556d8227bbce7dd5c06dc73040 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Mon, 14 Nov 2022 09:26:19 +0700 Subject: refactor: Support querying on project name --- code/api/src/Endpoints/V1/Projects/GetProjectsRoute.cs | 11 ++++------- 1 file 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>> HandleAsync(GetProjectsQueryParameters request, CancellationToken cancellationToken = default) { + public override async Task>> 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 -- cgit v1.3