I have some fairly simple state needs (for now). I think I would like to model these using the Stateless api. (But I don't really know much about state machines, so I could be wrong.)
But I am getting caught up in the terminology (Specifically State and Trigger)
Here is an example: I have an order class. It is setup with several states. They are: New, Filled, Shipping, Completed, Cancelled.
A few simple state rules I would like is that these state transitions are allowed:
- New (is the default)
- New -> Filled
- New -> Cancelled
- Filled -> Shipping
- Filled -> Cancelled
- Filled -> Shipping
- Shipping -> Complete
So where I am getting tripped up here is what is my "Trigger"?
Just in case a more specific example is needed, say I want a method like this:
public bool UpdateOrderStatus(int OrderId, OrderStatusEnum NewOrderStatus)
that will return true if the status updated successfully. How can setup and use Stateless to make this happen?
I believe, the trigger is this triggering event.
Update:
Of course trigger name sometimes can be equal to some of state names.
Update:
stateless is really nice framework! I've tried to implemented the functionality.
States:
Triggers:
Order class:
Tester for Order class: