-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented sub actions : new, unpublish, retract (#2933)
- Loading branch information
1 parent
7bd4df2
commit 1d56c64
Showing
7 changed files
with
149 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Elsa.Management.Contracts; | ||
using Elsa.Persistence.Models; | ||
using Elsa.Runtime.Contracts; | ||
using Elsa.Serialization; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Elsa.Api.Endpoints.Workflows; | ||
|
||
public static partial class Workflows | ||
{ | ||
public static async Task<IResult> PublishAsync(string definitionId, WorkflowSerializerOptionsProvider serializerOptionsProvider, IWorkflowRegistry workflowRegistry, | ||
IWorkflowPublisher workflowPublisher, CancellationToken cancellationToken) | ||
{ | ||
var workflow = await workflowRegistry.FindByIdAsync(definitionId, VersionOptions.Latest, cancellationToken); | ||
if (workflow == null) | ||
{ | ||
return Results.NotFound(); | ||
} | ||
|
||
if (workflow.Publication.IsPublished) | ||
{ | ||
return Results.BadRequest(new | ||
{ | ||
Message = $"Workflow with id {definitionId} is already published" | ||
}); | ||
} | ||
|
||
await workflowPublisher.PublishAsync(workflow, cancellationToken); | ||
var serializerOptions = serializerOptionsProvider.CreateApiOptions(); | ||
|
||
return Results.Json(workflow, serializerOptions, statusCode: StatusCodes.Status202Accepted); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Elsa.Management.Contracts; | ||
using Elsa.Persistence.Models; | ||
using Elsa.Runtime.Contracts; | ||
using Elsa.Serialization; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace Elsa.Api.Endpoints.Workflows; | ||
|
||
public static partial class Workflows | ||
{ | ||
public static async Task<IResult> RetractAsync(string definitionId, WorkflowSerializerOptionsProvider serializerOptionsProvider, IWorkflowRegistry workflowRegistry, | ||
IWorkflowPublisher workflowPublisher, CancellationToken cancellationToken) | ||
{ | ||
var workflow = await workflowRegistry.FindByIdAsync(definitionId, VersionOptions.LatestOrPublished, cancellationToken); | ||
if (workflow == null) | ||
{ | ||
return Results.NotFound(); | ||
} | ||
|
||
await workflowPublisher.RetractAsync(workflow, cancellationToken); | ||
var serializerOptions = serializerOptionsProvider.CreateApiOptions(); | ||
|
||
return Results.Json(workflow, serializerOptions, statusCode: StatusCodes.Status202Accepted); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters