1
This commit is contained in:
23
Yes.Blog/Endpoints/Admins/Comments/DeleteCommentEndpoint.cs
Normal file
23
Yes.Blog/Endpoints/Admins/Comments/DeleteCommentEndpoint.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
namespace Yes.Blog.Endpoints.Admins.Comments
|
||||
{
|
||||
public class DeleteCommentEndpoint : AdminEndpointScheme, IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder app) => app.MapDelete("/comments", Handle);
|
||||
|
||||
public record Request(int Id);
|
||||
|
||||
|
||||
private async Task<IResult> Handle([AsParameters] Request request, IMediator mediator, IMapper mapper, CancellationToken cancellationToken)
|
||||
{
|
||||
var command = new DeleteCommentCommand(request.Id);
|
||||
var response = await mediator.Send(command, cancellationToken);
|
||||
|
||||
|
||||
return Result.Ok(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
22
Yes.Blog/Endpoints/Admins/Comments/GetCommentsEndpoint.cs
Normal file
22
Yes.Blog/Endpoints/Admins/Comments/GetCommentsEndpoint.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace Yes.Blog.Endpoints.Admins.Comments
|
||||
{
|
||||
public class GetCommentsEndpoint : AdminEndpointScheme, IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder app) => app.MapGet("/comments", Handle);
|
||||
|
||||
public record Request(int? PageIndex);
|
||||
|
||||
|
||||
private async Task<IResult> Handle(
|
||||
[AsParameters] Request request,
|
||||
IMediator mediator,
|
||||
IMapper mapper,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var query = new GetCommentsQuery(request.PageIndex, 15);
|
||||
var response = await mediator.Send(query, cancellationToken);
|
||||
|
||||
return Result.Ok(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Yes.Blog.Endpoints.Admins.Comments
|
||||
{
|
||||
public class GetLatestCommentsEndpoint : AdminEndpointScheme, IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder app) => app.MapGet("/comments/Latest", Handle);
|
||||
|
||||
|
||||
|
||||
private async Task<IResult> Handle(
|
||||
IMediator mediator,
|
||||
IMapper mapper,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var query = new GetLatestCommentsQuery();
|
||||
var response = await mediator.Send(query, cancellationToken);
|
||||
|
||||
return Result.Ok(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
Yes.Blog/Endpoints/Admins/Comments/UpdateCommentEndpoint.cs
Normal file
27
Yes.Blog/Endpoints/Admins/Comments/UpdateCommentEndpoint.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace Yes.Blog.Endpoints.Admins.Comments
|
||||
{
|
||||
public class UpdateCommentEndpoint : AdminEndpointScheme, IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder app) => app.MapPut("/comments", Handle);
|
||||
|
||||
public record Request(int Id);
|
||||
|
||||
public class RequestValidator : AbstractValidator<Request>
|
||||
{
|
||||
public RequestValidator()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<IResult> Handle([AsParameters] Request request, IMediator mediator, IMapper mapper, CancellationToken cancellationToken)
|
||||
{
|
||||
var command = new UpdateCommentCommand(request.Id);
|
||||
var response = await mediator.Send(command, cancellationToken);
|
||||
|
||||
|
||||
return Result.Ok(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user