You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario: A product is created. A notification is sent to approver for approval. If approved/rejected it updates the product status in db. Trying to achieve this using Workflow-Core in .net application.
//Below is the builder:
public void Build(IWorkflowBuilder builder)
{
builder
.StartWith < **CreateProductStep * *> ()
.WaitFor("ApprovedProduct", (data, context) => data.ProductId)
.Then < **ApproveRejectStep * *> ();
}
//These are the workflow steps:
public class CreateProductStep : StepBody
{
public override ExecutionResult Run(IStepExecutionContext context)
{
var data = context.Workflow.Data as MyData;
Console.WriteLine($"Product created {data.ProductId} {data.IsApproved}");
return ExecutionResult.Next();
}
}
public class ApproveRejectStep : StepBody
{
public override ExecutionResult Run(IStepExecutionContext context)
{
var data = context.Workflow.Data as MyData;
Expecting the WaitFor to get the context of the first step:CreateProductStep and pass it to the next step:ApproveRejectStep. Which is not happening. What am I missing here. How can I achieve passing the context of the previous flow to the next waitfor step and invoke via api.
The text was updated successfully, but these errors were encountered:
Scenario: A product is created. A notification is sent to approver for approval. If approved/rejected it updates the product status in db. Trying to achieve this using Workflow-Core in .net application.
//Below is the builder:
public void Build(IWorkflowBuilder builder)
{
builder
.StartWith < **CreateProductStep * *> ()
.WaitFor("ApprovedProduct", (data, context) => data.ProductId)
.Then < **ApproveRejectStep * *> ();
}
//These are the workflow steps:
public class CreateProductStep : StepBody
{
public override ExecutionResult Run(IStepExecutionContext context)
{
var data = context.Workflow.Data as MyData;
}
public class ApproveRejectStep : StepBody
{
public override ExecutionResult Run(IStepExecutionContext context)
{
var data = context.Workflow.Data as MyData;
}
//The Controller:
[HttpPost("addproduct")]
public async Task AddProduct([FromBody] MyData product)
{
var workflowId = await _workflowHost.StartWorkflow("ProductWorkflow1", product);
return Ok(new { WorkflowId = workflowId, Message = "Product added and workflow started." });
}
[HttpPost("approve-reject-product")]
public async Task ApproveRejectProduct([FromBody] MyData product)
{
await _workflowHost.PublishEvent("ApprovedProduct", product.ProductId, product);
}
Expecting the WaitFor to get the context of the first step:CreateProductStep and pass it to the next step:ApproveRejectStep. Which is not happening. What am I missing here. How can I achieve passing the context of the previous flow to the next waitfor step and invoke via api.
The text was updated successfully, but these errors were encountered: