Add a Creator property on Content

This commit is contained in:
Jonathan Bourdon
2024-08-03 23:23:37 -04:00
parent 0340904847
commit e560dfccc1
4 changed files with 18 additions and 24 deletions

View File

@@ -26,7 +26,7 @@ public class GetContent(
{
var content = await context
.Contents
.FirstOrDefaultAsync(
.SingleOrDefaultAsync(
c => c.Id == req.ContentId,
cancellationToken: ct);

View File

@@ -4,26 +4,26 @@ using Microsoft.EntityFrameworkCore;
namespace Hutopy.Web.Features.Contents.Handlers;
public sealed class GetContentsByUserRequest
public sealed class GetContentsByCreatorRequest
{
public Guid UserId { get; set; }
[BindFrom("page_size")] public int PageSize { get; set; } = 10;
[BindFrom("last_id")] public Guid? LastId { get; set; }
}
public class GetContentsByUser(
public class GetContentsByCreatorHandler(
ContentDbContext context)
: Endpoint<GetContentsByUserRequest, List<Content>>
: Endpoint<GetContentsByCreatorRequest, List<Content>>
{
public override void Configure()
{
Get("/api/contents/user/{UserId:guid}");
Get("/api/contents/creator/{UserId:guid}");
Options(o => o.WithTags("Contents"));
AllowAnonymous();
}
public override async Task HandleAsync(
GetContentsByUserRequest req,
GetContentsByCreatorRequest req,
CancellationToken ct)
{
var query = context