Moved features to a specific folder

This commit is contained in:
Jonathan Bourdon
2024-07-18 22:22:44 -04:00
parent 98c85265f1
commit b34a775a4b
23 changed files with 32 additions and 37 deletions

View File

@@ -0,0 +1,38 @@
using FastEndpoints;
using Hutopy.Web.Features.Contents.Data;
using Microsoft.EntityFrameworkCore;
namespace Hutopy.Web.Features.Contents.Handlers;
public sealed class GetContentsRequest
{
public Guid ContentId { get; set; }
}
public class GetContents(
ContentDbContext context)
: Endpoint<GetContentsRequest, Content>
{
public override void Configure()
{
Get("/api/contents/{ContentId:guid}");
Options(o => o.WithTags("Contents"));
AllowAnonymous();
}
public override async Task HandleAsync(
GetContentsRequest req,
CancellationToken ct)
{
var content = await context
.Contents
.FirstOrDefaultAsync(
c => c.Id == req.ContentId,
cancellationToken: ct);
if (content is null)
await SendNotFoundAsync(cancellation: ct);
else
await SendAsync(content, cancellation: ct);
}
}