An overloaded version of the Get endpoint on the BooksController which takes a query string containing the following required fields:
pageNumber
The page number to return
perPage
The number of records to return per page
These fields are then used to filter the number of returned records. As an example: if the user sends the following query string data pageNumber=1&perPage=15, then the first 15 records will be returned.
Similarly, if the user sends the following query string pageNumber=2&perPage=15, then the second 15 records will be returned - as it is requesting page 2.
The following fields can also be provided, but they will not be used by this piece of work:
sortColumn
Which column (if any) to sort the returned data by
sortDirection
Which direction (ASC or DESC) to sort by
If not present DESC is assumed
searchQuery
An arbitrary string to all data fields by
High-Level Proposed Solution
A Get API action on the BooksController which takes a POCO which represents the paged request data
Use the [FromQuery] attribute on the argument to force ASP .NET Core to map data from the query string
A new interface (perhaps called IGetPaged) is created and implemented by the FlatFilebookService
The service returns a new POCO which has the following fields:
PageNumber (int)
PerPage (int)
Records (List of Book)
If a page of Book records could be returned by the service, then a 200 response is returned with the POCO in the body
If a page of Book records could not be returned by the service, then a 404 response is returned
Considerations
A number of new POCOs will be required:
PagedRequest
PageNumber (int)
PerPage (int)
SortColumn (string)
SortDirection (bool)
SearchQuery (string)
PagedResponse
PageNumber (int)
PerPage (int)
Records (List of Book)
Future versions of the API might require the PagedResponse POCO to be generic. However, this version of the API does not require that functionality.
It is recommended that this work is completed after #1, as this work is less trivial.
Requirements
The overloaded Get API action should take a POCO from the QueryString which matches the PagedRequest design above
The IGetPaged (or similarly named) interface should use the values in the PagedRequest POCO
The IGetPaged (or similarly named) interface should return an instance of the PagedResponse POCO
If there are no records in the PagedResponse POCO, then the API action should return a 404 with no data in the body
If there are records in the PagedResponse POCO, then the API action should return a 200 with the PagedResponse in the body.
Description
An overloaded version of the
Get
endpoint on theBooksController
which takes a query string containing the following required fields:pageNumber
perPage
These fields are then used to filter the number of returned records. As an example: if the user sends the following query string data
pageNumber=1&perPage=15
, then the first 15 records will be returned.Similarly, if the user sends the following query string
pageNumber=2&perPage=15
, then the second 15 records will be returned - as it is requesting page 2.The following fields can also be provided, but they will not be used by this piece of work:
sortColumn
sortDirection
searchQuery
High-Level Proposed Solution
Get
API action on theBooksController
which takes a POCO which represents the paged request data[FromQuery]
attribute on the argument to force ASP .NET Core to map data from the query stringIGetPaged
) is created and implemented by theFlatFilebookService
PageNumber
(int)PerPage
(int)Records
(List of Book)Considerations
A number of new POCOs will be required:
PagedRequest
PageNumber
(int)PerPage
(int)SortColumn
(string)SortDirection
(bool)SearchQuery
(string)PagedResponse
PageNumber
(int)PerPage
(int)Records
(List of Book)Future versions of the API might require the
PagedResponse
POCO to be generic. However, this version of the API does not require that functionality.It is recommended that this work is completed after #1, as this work is less trivial.
Requirements
Get
API action should take a POCO from the QueryString which matches thePagedRequest
design aboveIGetPaged
(or similarly named) interface should use the values in thePagedRequest
POCOIGetPaged
(or similarly named) interface should return an instance of thePagedResponse
POCOPagedResponse
POCO, then the API action should return a 404 with no data in the bodyPagedResponse
POCO, then the API action should return a 200 with thePagedResponse
in the body.