Step 4: Specifying the Order of Transitions (Optional)

Transitions are checked based on their order of declaration in code. To specify that a transition should be checked before or after another transition, you should call the PlaceBefore or PlaceAfter method,

In Step 3: Grouping Transitions and Adding Conditions to Transitions, you defined two transitions from the onHold state: one to the readyForAssignment state, and one to the pendingPayment state. Suppose that you want to make sure that the transition from the onHold state to the pendingPayment is always checked before the transition from the same state to the readyForAssignment state. To explicitly specify this order of transitions, call the PlaceBefore method in the transition definition from the onHold state to the pendingPayment state, as the following code shows.

                    .WithTransitions(transitions =>
                    {     
                        transitions.AddGroupFrom<States.onHold>(ts =>
                        {
                            ts.Add(t => t.To<States.readyForAssignment>()
                                .IsTriggeredOn(g => g.ReleaseFromHold)
                                .When(conditions.DoesNotRequirePrepayment));
                            ts.Add(t => t.To<States.pendingPayment>()
                                .IsTriggeredOn(g => g.ReleaseFromHold)
                                .When(conditions.RequiresPrepayment)
                                .PlaceBefore(tr => tr.To<States.readyForAssignment>()));
                        });
                    })

In this code,you have called the PlaceBefore method after calling the When method. Notice that you have passed in a lambda expression as a parameter to the PlaceBefore method, and within it, you have specified t.To<States.readyForAssignment>() as the transition before which you want the transition being defined to be checked.