public static bool IsStudent(string userEmail) { EKvizDbContext db = new EKvizDbContext(); if (db.Students.Any(p => p.EMail == userEmail)) { return true; } return false; }
public static bool IsProfessor(string userEmail) { EKvizDbContext db = new EKvizDbContext(); if (db.Professors.Any(p => p.EMail == userEmail)) { return true; } return false; }
public static bool IsUserLoggedIn(string userEmail, string userToken) { EKvizDbContext db = new EKvizDbContext(); if (db.Students.Any(s => s.EMail == userEmail && s.SessionHash == userToken)) { if ((DateTime.Now - db.Students.First(s => s.EMail == userEmail).TimeOfLastAction).Minutes < int.Parse(ConfigurationManager.AppSettings["UserLoggedInTime"])) { db.Students.First(s => s.EMail == userEmail).TimeOfLastAction = DateTime.Now; db.SaveChanges(); return true; } } if (db.Professors.Any(p => p.EMail == userEmail && p.SessionHash == userToken)) { if ((DateTime.Now - db.Professors.First(s => s.EMail == userEmail).TimeOfLastAction).Minutes < int.Parse(ConfigurationManager.AppSettings["UserLoggedInTime"])) { db.Professors.First(s => s.EMail == userEmail).TimeOfLastAction = DateTime.Now; db.SaveChanges(); return true; } } return false; }