Almost finish implementing client side

This commit is contained in:
2025-11-06 20:22:16 +02:00
parent a847779582
commit a891a686fd
42 changed files with 6450 additions and 57 deletions

View File

@@ -328,15 +328,15 @@ public class PostController(
/// Get a paginated list of posts.
/// </summary>
/// <param name="query">Query to filter posts by tags. Use +tag-name to require a tag, -tag-name to exclude a tag.</param>
/// <param name="pageNumber">The page number.</param>
/// <param name="page">The page number.</param>
/// <response code="200">The paginated list</response>
/// <response code="400">If request is malformed</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<ActionResult<PagedList<PostDto>>> GetAll(string? query, [Range(1, int.MaxValue)] int pageNumber = 1)
public async Task<ActionResult<PagedList<PostDto>>> GetAll(string? query, [Range(1, int.MaxValue)] int page = 1)
{
var list = await postService.FindAll(query, pageNumber);
var list = await postService.FindAll(query, page);
var newItems = list.Items.Select(i =>
{
var fileUrl = Url.Action(nameof(PatchFileContent), "Post",
@@ -494,7 +494,7 @@ public class PostController(
/// Get paginated list of specific post comments.
/// </summary>
/// <param name="postId">Post ID</param>
/// <param name="pageNumber">Page number</param>
/// <param name="page">Page number</param>
/// <response code="200">Paginated list of comments</response>
/// <response code="400">If request is malformed</response>
/// <response code="404">If post is not found</response>
@@ -504,13 +504,13 @@ public class PostController(
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<PagedList<CommentDto>>> GetAllComments(
int postId,
[Range(1, int.MaxValue)] int pageNumber = 1
[Range(1, int.MaxValue)] int page = 1
)
{
var post = await postService.GetById(postId);
if (post == null) return NotFound();
var list = await commentService.GetAll(postId, pageNumber);
var list = await commentService.GetAll(postId, page);
var newItems = list.Items.Select(CommentDto.FromComment).ToList();
return Ok(new PagedList<CommentDto>(newItems, list.CurrentPage, list.PageSize, list.TotalCount));
}