public void Configure(TravelRequestStateMachineContext context) { context.StateMachine.Configure(TravelRequestState.TravelerReview) .PermitIf(TravelRequestAction.Accept, TravelRequestState.ManagerApproval, () => context.CurrentTravelRequest.Traveller == _userSecurityContext.CurrentUser) .OnEntry(() => _notifier.Notify("NotifyTravellerOfReview", context.CurrentTravelRequest), "Notify Traveller") .OnEntry(() => _notifier.Notify("NotifyTravelAdminOfReview", context.CurrentTravelRequest), "Notify Travel Admin"); }
public void Configure(TravelRequestStateMachineContext context) { context.StateMachine.Configure(TravelRequestState.HODApproval) .PermitIf(TravelRequestAction.Approve, TravelRequestState.BookTickets, () => context.CurrentTravelRequest.Approver == _userSecurityContext.CurrentUser) .OnEntryFrom(TravelRequestAction.Approve, transition => { if (context.CurrentTravelRequest.IsEmployee) { context.StateMachine.Fire(TravelRequestAction.Approve); } }); }
public ReusableTravelRequestStateMachine(List <IReusableTravelRequestStateMachineConfigurator> configurators) { if (configurators == null) { throw new ArgumentNullException(nameof(configurators)); } var stateMachine = new StateMachine <TravelRequestState, TravelRequestAction>(GetState, SetState); _stateMachineContext = new TravelRequestStateMachineContext(stateMachine); configurators.ForEach(configurator => configurator.Configure(_stateMachineContext)); }
public void Configure(TravelRequestStateMachineContext context) { context.StateMachine.Configure(TravelRequestState.ManagerApproval) .PermitIf(TravelRequestAction.Approve, TravelRequestState.ProcurementApproval, () => context.CurrentTravelRequest.Approver == _userSecurityContext.CurrentUser); }