Implemented UpdateUserStatusEndpoint
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Users;
|
||||
using PostFundManagement.Domain;
|
||||
using PostFundManagement.Domain.Abstractions;
|
||||
using PostFundManagement.Domain.Extensions;
|
||||
using PostFundManagement.Domain.Security;
|
||||
|
||||
namespace PostFundManagement.Api.Endpoints.Users;
|
||||
|
||||
[ApiVersionTarget(1)]
|
||||
public sealed class UpdateUserStatusEndpoint : IEndpoint
|
||||
{
|
||||
public void Map(IEndpointRouteBuilder builder)
|
||||
{
|
||||
builder.MapGet("api/users/{userId:Guid}/status/{status:int}", async (Guid userId, ActivityStatus status,
|
||||
UserService service, CancellationToken cancellationToken = default) =>
|
||||
{
|
||||
var result = await service.UpdateUserStatusAsync(userId, status, cancellationToken);
|
||||
|
||||
return result.IsSuccess
|
||||
? Results.Ok()
|
||||
: Results.NotFound();
|
||||
})
|
||||
.WithDescription("Changes the Activity status of the user in the system")
|
||||
.WithName(typeof(UpdateUserStatusEndpoint).ToEndpointName())
|
||||
.MapToApiVersion(new ApiVersion(1))
|
||||
.Produces(StatusCodes.Status200OK)
|
||||
.Produces(StatusCodes.Status404NotFound)
|
||||
.Produces(StatusCodes.Status401Unauthorized)
|
||||
.WithTags(EndpointTags.Users);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user