void LogSessionAsync(string browser, string ip, User user, string sessionId)
        {
            new Thread(new ThreadStart(() =>
            {
                try
                {
                    using (var db = new AlumniDbContext())
                    {
                        var session = new Session();
                        session.Browser = browser;
                        session.IPAddress = ip;
                        session.UserName = user.FullName;
                        session.Start = DateTime.UtcNow;
                        session.UserId = user.UserId;
                        session.SessionId = sessionId;

                        var pastActSession = db.UserSessions.Where(s => s.UserId == user.UserId && s.End == null && s.IPAddress ==  ip);
                        foreach (var item in pastActSession)
                        {
                            item.End = DateTime.UtcNow;
                            db.Entry(item).State = System.Data.EntityState.Modified;
                        }

                        db.UserSessions.Add(session);
                        db.SaveChanges();
                    }
                }
                catch { }
            })).Start();
        }
 void LogOutSessionAsync(string sessionId)
 {
     new Thread(new ThreadStart(() =>
     {
         using (var db = new AlumniDbContext())
         {
             try
             {
                 var session = db.UserSessions.Where(s => s.SessionId == sessionId)
                                 .ToList().Last();
                 if (session != null)
                 {
                     session.End = DateTime.UtcNow;
                     db.SaveChanges();
                 }
             }
             catch { }
         }
     })).Start();
 }