Adds an `.editorconfig` file with C# and project-specific conventions. Applies consistent indentation and formatting across backend handlers, runtime models, and AI services.
32 lines
949 B
C#
32 lines
949 B
C#
using FastEndpoints;
|
|
|
|
namespace SpaceGame.Api.PlayerFaction.Api;
|
|
|
|
public sealed class UpsertPlayerAssignmentHandler(WorldService worldService) : Endpoint<PlayerAssetAssignmentCommandRequest, PlayerFactionSnapshot>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Put("/api/player-faction/assets/{assetId}/assignment");
|
|
AllowAnonymous();
|
|
}
|
|
|
|
public override async Task HandleAsync(PlayerAssetAssignmentCommandRequest request, CancellationToken cancellationToken)
|
|
{
|
|
var assetId = Route<string>("assetId");
|
|
if (string.IsNullOrWhiteSpace(assetId))
|
|
{
|
|
await SendNotFoundAsync(cancellationToken);
|
|
return;
|
|
}
|
|
|
|
var snapshot = worldService.UpsertPlayerAssignment(assetId, request);
|
|
if (snapshot is null)
|
|
{
|
|
await SendNotFoundAsync(cancellationToken);
|
|
return;
|
|
}
|
|
|
|
await SendOkAsync(snapshot, cancellationToken);
|
|
}
|
|
}
|