36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using FastEndpoints;
|
|
|
|
namespace SpaceGame.Api.Ships.Api;
|
|
|
|
public sealed class GetShipAutomationCatalogHandler : EndpointWithoutRequest<ShipAutomationCatalogSnapshot>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Get("/api/ships/catalog");
|
|
AllowAnonymous();
|
|
}
|
|
|
|
public override async Task HandleAsync(CancellationToken cancellationToken)
|
|
{
|
|
var snapshot = new ShipAutomationCatalogSnapshot(
|
|
ShipAutomationCatalog.Behaviors
|
|
.Select(definition => new ShipBehaviorDefinitionSnapshot(
|
|
definition.Id,
|
|
definition.Label,
|
|
definition.Category,
|
|
definition.SupportStatus.ToString(),
|
|
definition.Notes))
|
|
.ToList(),
|
|
ShipAutomationCatalog.Orders
|
|
.Select(definition => new ShipOrderDefinitionSnapshot(
|
|
definition.Id,
|
|
definition.Label,
|
|
definition.Category,
|
|
definition.SupportStatus.ToString(),
|
|
definition.Notes))
|
|
.ToList());
|
|
|
|
await SendOkAsync(snapshot, cancellationToken);
|
|
}
|
|
}
|