// State type with transitions
public class ApprovalState : DbObservableObject, IDbStateEnum
{
public Guid Id { get; set; }
public string DisplayName { get; set; }
public int SortOrder { get; set; }
public bool IsActive { get; set; }
// State machine specific
public string InstructionText { get; set; }
public string PrimaryTargetDisplayText { get; set; }
public int PrimaryTargetSortOrder { get; set; }
public string SecondaryTargetDisplayText { get; set; }
public int SecondaryTargetSortOrder { get; set; }
}
// Entity in workflow
public class ApprovalRequest : DbObservableObject, IHasState<ApprovalState>
{
public Guid Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
// State relationship
public Guid StateTypeId { get; set; }
public ApprovalState StateType { get; set; }
}
// Database seed data with transitions
var states = new[]
{
new ApprovalState
{
Id = Guid.NewGuid(),
DisplayName = "Created",
SortOrder = 0,
IsActive = true,
InstructionText = "Request created and awaiting submission",
PrimaryTargetDisplayText = "Submit for Review",
PrimaryTargetSortOrder = 10,
SecondaryTargetDisplayText = "Cancel",
SecondaryTargetSortOrder = 98
},
new ApprovalState
{
Id = Guid.NewGuid(),
DisplayName = "Under Review",
SortOrder = 10,
IsActive = true,
InstructionText = "Request is being reviewed by approver",
PrimaryTargetDisplayText = "Approve",
PrimaryTargetSortOrder = 20,
SecondaryTargetDisplayText = "Reject",
SecondaryTargetSortOrder = 99
},
new ApprovalState
{
Id = Guid.NewGuid(),
DisplayName = "Approved",
SortOrder = 20,
IsActive = true,
InstructionText = "Request has been approved",
PrimaryTargetDisplayText = "Complete",
PrimaryTargetSortOrder = 100,
SecondaryTargetDisplayText = "Revert to Review",
SecondaryTargetSortOrder = 10
}
};