private SessionBLL GetUserSession(UserBLL user)
 {
     using (var context = new AuctionSiteContext(ConnectionString))
     {
         var session = context.Sessions.Find(Utils.CreateSessionId(this, user));
         if (null == session)
         {
             user.Session = Utils.CreateNewSession(this, user);
             return(user.Session);
         }
         var sessionBLL = new SessionBLL(session, user);
         if (!sessionBLL.IsValid())
         {
             sessionBLL.Logout();
             user.Session = Utils.CreateNewSession(this, user);
         }
         else
         {
             var validUntil = AlarmClock.Now.AddSeconds(SessionExpirationInSeconds);
             session.ValidUntil           = validUntil;
             user.Session.ValidUntil      = validUntil;
             context.Entry(session).State = EntityState.Modified;
             context.SaveChanges();
         }
         return(user.Session);
     }
 }
Beispiel #2
0
 public UserBLL(User user, ISite site)
 {
     UserID   = user.UserID;
     Username = user.Username;
     Password = user.Password;
     Site     = site as SiteBLL;
     Salt     = user.Salt;
     if (null != user.Session)
     {
         Session = new SessionBLL(user.Session, this);
     }
 }