Step 2: Adding a State and a Transition

In this step, you will define the Completed state and the transition from the Assigned state to the Completed state. Do the following:

  1. In the lambda expression for the WithFlowStates method, add the definition of the Completed state, as the following code shows.
                            fss.Add<States.completed>(flowState =>
                            {
                                return flowState
                                    .WithFieldStates(states =>
                                    {
                                        states.AddField<RSSVWorkOrder.customerID>(state
                                          => state.IsDisabled());
                                        states.AddField<RSSVWorkOrder.serviceID>(state
                                          => state.IsDisabled());
                                        states.AddField<RSSVWorkOrder.deviceID>(state
                                          => state.IsDisabled());
                                    });
                            });

    In the state configuration, you have made the CustomerID, ServiceID, and DeviceID fields disabled.

  2. In the WithTransitions method, define the transition from the Assigned state to the Completed state, as the following code shows.
                            transitions.AddGroupFrom<States.assigned>(ts =>
                            {
                                ts.Add(t => t.To<States.completed>().IsTriggeredOn(g 
                                  => g.Complete));
                            });