using FastEndpoints;using Shared.Problems;
namespace Modules.OMS.Orders.Register;
public sealed class UpdateEndpoint(RegisterOrderHandler handler):Endpoint<RegisterOrderRequest,RegisterOrderResponse>{public override void Configure(){Put("/api/oms/orders/{id}");Permissions("oms.order.write");}public override async Task HandleAsync(RegisterOrderRequest req,CancellationToken ct){var id=Route<Guid>("id");var result=await handler.HandleAsync(req with{OrderId=id},User,ct);if(result.Problem is KbxValidationProblem v){await Send.ResponseAsync(v,400,cancellation:ct);return;}if(result.Problem is KbxBusinessProblem b){await Send.ResponseAsync(b,409,cancellation:ct);return;}if(result.Problem is KbxConflictProblem c){await Send.ResponseAsync(c,409,cancellation:ct);return;}await Send.OkAsync(result.Response!,ct);}}
