-
Notifications
You must be signed in to change notification settings - Fork 492
Expand file tree
/
Copy pathPrepareContractEndpoint.cs
More file actions
26 lines (23 loc) · 1.22 KB
/
PrepareContractEndpoint.cs
File metadata and controls
26 lines (23 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
namespace EvolutionaryArchitecture.Fitnet.Contracts.Api.Prepare;
using Application;
using Common.Api.Validation.Requests;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
internal static class PrepareContractEndpoint
{
internal static void MapPrepareContract(this IEndpointRouteBuilder app) => app.MapPost(ContractsApiPaths.Prepare,
async (PrepareContractRequest request, IContractsModule contractsModule,
CancellationToken cancellationToken) =>
{
var command = request.ToCommand();
var contractId = await contractsModule.ExecuteCommandAsync(command, cancellationToken);
return Results.Created($"/{ContractsApiPaths.Prepare}/{contractId}", contractId);
})
.ValidateRequest<PrepareContractRequestValidator>()
.WithSummary("Triggers preparation of a new contract for new or existing customer")
.WithDescription("This endpoint is used to prepare a new contract for new and existing customers.")
.Produces<string>(StatusCodes.Status201Created)
.Produces(StatusCodes.Status409Conflict)
.Produces(StatusCodes.Status500InternalServerError);
}