File tree Expand file tree Collapse file tree
src/ApiService/BookStore.ApiService/Endpoints Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,7 +39,10 @@ static async Task<Ok<PagedListDto<BookDto>>> SearchBooks(
3939 [ FromServices ] IOptions < LocalizationOptions > localizationOptions ,
4040 [ AsParameters ] PagedRequest request ,
4141 HttpContext context ,
42- [ FromQuery ] string ? search = null )
42+ [ FromQuery ] string ? search = null ,
43+ [ FromQuery ] Guid ? authorId = null ,
44+ [ FromQuery ] Guid ? categoryId = null ,
45+ [ FromQuery ] Guid ? publisherId = null )
4346 {
4447 var paging = request . Normalize ( paginationOptions . Value ) ;
4548
@@ -68,6 +71,21 @@ static async Task<Ok<PagedListDto<BookDto>>> SearchBooks(
6871 ( b . Isbn != null && b . Isbn . Contains ( searchQuery ) ) ) ;
6972 }
7073
74+ if ( authorId . HasValue )
75+ {
76+ query = ( Marten . Linq . IMartenQueryable < BookSearchProjection > ) query . Where ( b => b . AuthorIds . Contains ( authorId . Value ) ) ;
77+ }
78+
79+ if ( categoryId . HasValue )
80+ {
81+ query = ( Marten . Linq . IMartenQueryable < BookSearchProjection > ) query . Where ( b => b . CategoryIds . Contains ( categoryId . Value ) ) ;
82+ }
83+
84+ if ( publisherId . HasValue )
85+ {
86+ query = ( Marten . Linq . IMartenQueryable < BookSearchProjection > ) query . Where ( b => b . PublisherId == publisherId . Value ) ;
87+ }
88+
7189 // Execute query with pagination
7290 var pagedList = await query
7391 . OrderBy ( b => b . Title )
You can’t perform that action at this time.
0 commit comments