Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage #26

Merged
merged 17 commits into from
Mar 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#9 Fixed search on books controller
  • Loading branch information
Dubravko Rittuper committed Jan 30, 2024
commit 9278e03381b41f1c9ceb08809d7a0da464dfa914
18 changes: 13 additions & 5 deletions Acme.Interface.WebAPI/Controllers/v1/BooksController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Acme.Interface.WebAPI.Controllers.v1.Base;
using Acme.Core.Paging.Enums;
using Acme.Interface.WebAPI.Controllers.v1.Base;
using Acme.Interface.WebAPI.Models.Books;
using Acme.Interface.WebAPI.Models.Paging;
using Acme.Interface.WebAPI.Services.Books;
Expand Down Expand Up @@ -30,16 +31,23 @@ public BooksController(IBooksApiService booksApiService)
/// <summary>
/// Gets all books paged asynchronously.
/// </summary>
/// <param name="pagingDto">The paged request DTO.</param>
/// <param name="page">The page.</param>
/// <param name="pageSize">Size of the page.</param>
/// <param name="sortColumn">The sort column.</param>
/// <param name="sortDirection">The sort direction.</param>
/// <returns>
/// Paged books.
/// </returns>
[HttpPost("search")]
[HttpGet("search")]
[ProducesResponseType(typeof(PagedResponseDto<BookDto>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> GetAllAsync([FromBody] PagedRequestDto pagingDto) =>
this.Ok(await this.booksApiService.GetAllAsync(pagingDto));
public async Task<IActionResult> GetAllAsync(
[FromQuery] int page = 0,
[FromQuery] int pageSize = 20,
[FromQuery] string sortColumn = "Id",
[FromQuery] SortDirection sortDirection = SortDirection.Ascending) =>
this.Ok(await this.booksApiService.GetAllAsync(new PagedRequestDto { Page = page, PageSize = pageSize, SortColumn = sortColumn, SortDirection = sortDirection }));

/// <summary>
/// Gets the book by its identifier asynchronously.
Expand Down
Loading