fix error

This commit is contained in:
2025-10-17 11:15:05 +02:00
parent bf0d8dbf60
commit a022ed2f38
11 changed files with 6 additions and 19 deletions

View File

@@ -10,7 +10,6 @@ public class CreateCommentEndpoint(BlogPlatformDbContext database) : Endpoint<Cr
public override void Configure()
{
Post("/api/comments");
AllowAnonymous();
}
public override async Task HandleAsync(CreateCommentDto req, CancellationToken ct)

View File

@@ -10,7 +10,6 @@ public class GetAllCommentsEndpoint(BlogPlatformDbContext database) : EndpointWi
public override void Configure()
{
Get("/api/comments");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)

View File

@@ -14,7 +14,6 @@ public class GetCommentEndpoint(BlogPlatformDbContext database) : Endpoint<GetCo
public override void Configure()
{
Get("/api/comments/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(GetCommentRequest req, CancellationToken ct)

View File

@@ -11,11 +11,11 @@ public class UpdateCommentEndpoint(BlogPlatformDbContext database) : Endpoint<Up
public override void Configure()
{
Put("/api/comments/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(UpdateCommentDto req, CancellationToken ct)
{
var comment = await database.Comments.FirstOrDefaultAsync(x => x.Id == req.Id, ct);
var checkUser = await database.Users.SingleOrDefaultAsync(x=> x.Id == req.UserId, ct);
var checkPost = await database.Posts.SingleOrDefaultAsync(x=> x.Id == req.PostId, ct);
@@ -24,14 +24,11 @@ public class UpdateCommentEndpoint(BlogPlatformDbContext database) : Endpoint<Up
await Send.NoContentAsync(ct);
return;
}
var comment = new Models.Comment()
{
Content = req.Content,
CreatedAt = DateOnly.FromDateTime(DateTime.UtcNow),
PostId = req.PostId,
UserId = req.UserId
};
comment.Content = req.Content;
comment.CreatedAt = DateOnly.FromDateTime(DateTime.UtcNow);
comment.PostId = req.PostId;
comment.UserId = req.UserId;
database.Comments.Add(comment);
await database.SaveChangesAsync(ct);

View File

@@ -10,7 +10,6 @@ public class CreatePostEndpoint(BlogPlatformDbContext database) : Endpoint<Creat
public override void Configure()
{
Post("/api/posts");
AllowAnonymous();
}
public override async Task HandleAsync(CreatePostDto req, CancellationToken ct)

View File

@@ -13,7 +13,6 @@ public class DeletePostEndpoint(BlogPlatformDbContext database) : Endpoint<Delet
public override void Configure()
{
Delete("/api/posts/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(DeletePostRequest req, CancellationToken ct)

View File

@@ -10,7 +10,6 @@ public class GetAllPostsEndpoint(BlogPlatformDbContext database) : EndpointWitho
public override void Configure()
{
Get("/api/posts");
AllowAnonymous();
}
public override async Task HandleAsync(CancellationToken ct)

View File

@@ -15,7 +15,6 @@ public class GetPostEndpoint(BlogPlatformDbContext database) : Endpoint<GetPostR
public override void Configure()
{
Get("/api/posts/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(GetPostRequest req, CancellationToken ct)

View File

@@ -11,7 +11,6 @@ public class PatchPostDecrementLikeEndpoint(BlogPlatformDbContext database) : En
public override void Configure()
{
Patch("/api/posts/{@Id}/DecrementLikes", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(PatchPostDecrementLikeDto req, CancellationToken ct)

View File

@@ -11,7 +11,6 @@ public class PatchPostIncrementLikeEndpoint(BlogPlatformDbContext database) : En
public override void Configure()
{
Patch("/api/posts/{@Id}/IncrementLikes", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(PatchPostIncrementLikeDto req, CancellationToken ct)

View File

@@ -11,7 +11,6 @@ public class UpdatePostEndpoint(BlogPlatformDbContext database) : Endpoint<Updat
public override void Configure()
{
Put("/api/posts/{@Id}", x => new {x.Id});
AllowAnonymous();
}
public override async Task HandleAsync(UpdatePostDto req, CancellationToken ct)