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