public ActionResult Index(User user) { if (ModelState.IsValid) { using (AGPModel db = new AGPModel()) { var obj = db.Users.Where(a => a.email.Equals(user.email) && a.password.Equals(user.password)).FirstOrDefault(); if (obj != null) { Session["ID"] = obj.ID.ToString(); Session["lastname"] = obj.lastname.ToString(); Session["firstname"] = obj.firstname.ToString(); Session["password"] = obj.password.ToString(); Session["email"] = obj.email.ToString(); Session["highschool"] = obj.highschool.ToString(); Session["institution"] = obj.institution.ToString(); Session["domain"] = obj.domain.ToString(); Session["filiere"] = obj.filiere.ToString(); //db.Users.Add(user); //db.SaveChanges(); return(RedirectToAction("Home")); } } } return(View(user)); }