public bool TryLogout(string sessionId)
 {
     if (!HasActiveSession(sessionId))
     {
         var noActive = new NoActiveSession
         {
             Message = string.Format("You do not have active session")
         };
         throw new FaultException<NoActiveSession>(noActive);
     }
     return _sessions.RemoveAll(s => s.SessionId == sessionId) > 0;
 }
 public void EnsureHasActiveSession(string sessionId)
 {
     if (!HasActiveSession(sessionId))
     {
         var noActive = new NoActiveSession
         {
             Message = string.Format("You do not have active session")
         };
         throw new FaultException<NoActiveSession>(noActive);
     }
 }
 public void CheckSessionTimeout(Session session)
 {
     TimeSpan ts = DateTime.Now - session.Time;
     if (ts.TotalSeconds > _timeout)
     {
         _sessions.RemoveAll(s => s.SessionId == session.SessionId);
         
         var noActive = new NoActiveSession
         {
             Message = string.Format("Your session has expired.")
         };
         throw new FaultException<NoActiveSession>(noActive);
         
     } 
     
     var dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
         
     session.Time = dt;
 }