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
919 B
C#
32 lines
919 B
C#
using FastEndpoints;
|
|
|
|
namespace SpaceGame.Api.Ships.Api;
|
|
|
|
public sealed class UpdateShipDefaultBehaviorHandler(WorldService worldService) : Endpoint<ShipDefaultBehaviorCommandRequest, ShipSnapshot>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Put("/api/ships/{shipId}/default-behavior");
|
|
AllowAnonymous();
|
|
}
|
|
|
|
public override async Task HandleAsync(ShipDefaultBehaviorCommandRequest request, CancellationToken cancellationToken)
|
|
{
|
|
var shipId = Route<string>("shipId");
|
|
if (string.IsNullOrWhiteSpace(shipId))
|
|
{
|
|
await SendNotFoundAsync(cancellationToken);
|
|
return;
|
|
}
|
|
|
|
var snapshot = worldService.UpdateShipDefaultBehavior(shipId, request);
|
|
if (snapshot is null)
|
|
{
|
|
await SendNotFoundAsync(cancellationToken);
|
|
return;
|
|
}
|
|
|
|
await SendOkAsync(snapshot, cancellationToken);
|
|
}
|
|
}
|