public void AriseEvent(string eventId)
        {
            StatesNet.PreviousStateId = StatesNet.CurrentState.Id;
            StatesNet.PreviousEventId = eventId;

            var nextStateId = StatesNet.CurrentState.AvaliableStatesIds[eventId];

            StatesNet.CurrentState = StatesNet.GetById(nextStateId);
        }
        private void StepInsideNet(StatesPath path, StatesNet net, State currentState, string finishStateId)
        {
            if (currentState.AvailableEvents.IsNullOrEmpty())
            {
                EndPath(path, currentState, StatesPathStatus.Blocked);
                return;
            }

            if (StateOccuredPreviously(path, currentState))
            {
                EndPath(path, currentState, StatesPathStatus.Unsuccessful);
                return;
            }

            if (currentState.Id.Equals(finishStateId))
            {
                EndPath(path, currentState, StatesPathStatus.Successful);
                return;
            }

            foreach (var availableEvent in currentState.AvailableEvents)
            {
                var currentNode = new StatesPathNode
                {
                    State          = currentState,
                    LeavingEventId = availableEvent
                };

                var iterationPath = Mapper.Map <StatesPath>(path);
                iterationPath.StatesPathCollection.Add(currentNode);

                var nextStateId = currentState.AvaliableStatesIds[availableEvent];
                var nextState   = net.GetById(nextStateId);

                StepInsideNet(iterationPath, net, nextState, finishStateId);
            }
        }
 public void Initialize(StatesNetJson statesNetJson)
 {
     StatesNet = Mapper.Map <StatesNet>(statesNetJson);
     StatesNet.CurrentState = StatesNet.GetById(statesNetJson.StartStateId);
 }