42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using FastEndpoints;
|
|
using MediatR;
|
|
using Workflow.Application.Features.WorkflowDefinitions.Commands;
|
|
using Workflow.Application.Features.WorkflowDefinitions.DTOs;
|
|
using Workflow.Domain.Enums;
|
|
|
|
namespace Workflow.Api.Endpoints.WorkflowDefinition;
|
|
|
|
public class UpdateEdgeEndpoint : Endpoint<UpdateEdgeRequest, WorkflowEdgeDto>
|
|
{
|
|
private readonly IMediator _mediator;
|
|
|
|
public UpdateEdgeEndpoint(IMediator mediator) => _mediator = mediator;
|
|
|
|
public override void Configure()
|
|
{
|
|
Put("/workflow-definitions/{DefinitionId}/edges/{EdgeId}");
|
|
AllowAnonymous();
|
|
Summary(s =>
|
|
{
|
|
s.Summary = "Update an edge in a workflow definition";
|
|
});
|
|
}
|
|
|
|
public override async Task HandleAsync(UpdateEdgeRequest req, CancellationToken ct)
|
|
{
|
|
var command = new UpdateEdgeCommand(req.EdgeId, (EdgeType)req.EdgeType, req.Label, req.Condition, req.Order);
|
|
var result = await _mediator.Send(command, ct);
|
|
await Send.OkAsync(result, ct);
|
|
}
|
|
}
|
|
|
|
public class UpdateEdgeRequest
|
|
{
|
|
public Guid DefinitionId { get; set; }
|
|
public Guid EdgeId { get; set; }
|
|
public int EdgeType { get; set; }
|
|
public string? Label { get; set; }
|
|
public string? Condition { get; set; }
|
|
public int Order { get; set; }
|
|
}
|