Implemented UpdateUserStatusEndpoint

This commit is contained in:
2026-08-30 15:38:34 +02:00
parent c6d1d862ff
commit 6c7db78e17
3 changed files with 61 additions and 9 deletions
@@ -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);
}
}