public ActionResult Index(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } var result = CheckCredential(model); switch (result) { case SignInStatus.Success: BDDAccess bddAccess = new BDDAccess(); if (bddAccess.Connect(Path.Combine(Server.MapPath("~"), "bdd.bin"))) { if (bddAccess.GetIdEtudiant((Session["User"] as User).FirstName, (Session["User"] as User).LastName) == -1) { bddAccess.CreateStudent((Session["User"] as User).FirstName, (Session["User"] as User).LastName, Student.GetClass((Session["User"] as User).Groups[0])); } } else { ViewBag.Error = bddAccess.Information; return(View("Error")); } if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Activity")); } case SignInStatus.ChangePasswordFirstUse: return(RedirectToAction("ChangePassword", "Manage", new { tips = "firstUse" })); case SignInStatus.AdminAccount: return(RedirectToAction("Index", "Administration")); case SignInStatus.Failure: default: ModelState.AddModelError("", "Tentative de connexion non valide."); return(View(model)); } }