Exemplo n.º 1
0
 internal static void Logout(string token)
 {
     using (CoreModel coreDAL = new CoreModel())
     {
         Account_Session session = coreDAL.Account_Session.FirstOrDefault(a => a.Token == token);
         coreDAL.Entry(session).State = System.Data.Entity.EntityState.Deleted;
         coreDAL.SaveChanges();
     }
 }
Exemplo n.º 2
0
        internal static string GetUserSessionByUserId(int userId)
        {
            using (CoreModel coreDAL = new CoreModel())
            {
                Account_Session session = coreDAL.Account_Session.FirstOrDefault(s => s.AccountId == userId);
                if (session != null)
                {
                    return(session.Token);
                }

                return(string.Empty);
            }
        }
Exemplo n.º 3
0
        internal static void AddSession(AccountSessionEntity session)
        {
            using (CoreModel coreDAL = new CoreModel())
            {
                Account_Session sess = new Account_Session()
                {
                    AccountId      = session.AccountId,
                    Token          = session.Token,
                    ExpirationDate = session.ExpirationDate,
                    LoginDate      = DateTime.Now
                };

                coreDAL.Account_Session.Add(sess);
                coreDAL.SaveChanges();
            }
        }
Exemplo n.º 4
0
 internal static AccountSessionEntity GetUserSession(string token)
 {
     using (CoreModel coreDAL = new CoreModel())
     {
         AccountSessionEntity account = null;
         Account_Session      session = coreDAL.Account_Session.Include("Account").FirstOrDefault(s => s.Token == token);
         if (session != null)
         {
             account = new AccountSessionEntity()
             {
                 AccountId      = session.AccountId,
                 Token          = session.Token,
                 LoginDate      = session.LoginDate,
                 ExpirationDate = session.ExpirationDate,
                 ClubId         = session.Account.ClubId
             };
         }
         return(account);
     }
 }