public void SetSessionState(Session session, SessionState state, string data = null)
        {
            SessionRepository.Change(session, delegate(ref Session s)
            {
                s.State = state;

                if (data != null)
                    s.StateJson = data;
            });
        }
 public void TerminateSession(Session session)
 {
     SessionRepository.Change(session, (ref Session s) => s.State = SessionState.Terminated);
 }