dotnet-cqrs/Svrnty.Sample/Workflows/InvitationWorkflow.cs

50 lines
1.7 KiB
C#

using Svrnty.CQRS.Events.Abstractions;
using Svrnty.CQRS.Events.Abstractions.Models;
namespace Svrnty.Sample.Workflows;
/// <summary>
/// Workflow for user invitation process (invite → accept/decline).
/// Manages event emission for multi-step invitation commands.
/// </summary>
/// <remarks>
/// <para>
/// <strong>Multi-Step Workflow:</strong>
/// This workflow demonstrates a multi-step business process:
/// 1. InviteUserCommand → UserInvitedEvent
/// 2. AcceptInviteCommand → UserInviteAcceptedEvent (OR)
/// DeclineInviteCommand → UserInviteDeclinedEvent
/// </para>
/// <para>
/// <strong>Correlation:</strong>
/// In Phase 1, each command creates a new workflow instance.
/// Future phases will support workflow continuation where multiple commands
/// can participate in the same workflow instance using the workflow ID.
/// </para>
/// <para>
/// <strong>Events Emitted:</strong>
/// - <see cref="UserInvitedEvent"/> when invitation is sent
/// - <see cref="UserInviteAcceptedEvent"/> when invitation is accepted
/// - <see cref="UserInviteDeclinedEvent"/> when invitation is declined
/// </para>
/// </remarks>
public class InvitationWorkflow : Workflow
{
// Helper methods for type-safe event emission
/// <summary>
/// Emits a UserInvitedEvent within this workflow.
/// </summary>
public void EmitInvited(UserInvitedEvent @event) => Emit(@event);
/// <summary>
/// Emits a UserInviteAcceptedEvent within this workflow.
/// </summary>
public void EmitAccepted(UserInviteAcceptedEvent @event) => Emit(@event);
/// <summary>
/// Emits a UserInviteDeclinedEvent within this workflow.
/// </summary>
public void EmitDeclined(UserInviteDeclinedEvent @event) => Emit(@event);
}