public ActionResult Index() { ElectionDatabaseEntities dbcand = new ElectionDatabaseEntities(); ElectionDatabaseEntities0 dbcompte = new ElectionDatabaseEntities0(); ElectionDatabaseEntities3 dbelect = new ElectionDatabaseEntities3(); int ncand = dbcand.Candidat.ToList <Candidat>().Count(); int nelect = dbelect.Electeur.ToList <Electeur>().Count(); int nadmin = dbcompte.Compte.ToList <Compte>().Count(); int total = 0; foreach (var item in dbcand.Candidat.ToList <Candidat>()) { total = (int)(total + item.voix); } ViewBag.candidats = ncand; ViewBag.electeurs = nelect; ViewBag.admins = nadmin; ViewBag.listecand = dbcand.Candidat.ToList <Candidat>(); ViewBag.totalvoix = total; return(View()); }
public ActionResult Connexion([Bind(Include = "login,password")] Compte compte) { ElectionDatabaseEntities0 db = new ElectionDatabaseEntities0(); if (ModelState.IsValid) { foreach (Compte c in db.Compte.ToList <Compte>()) { if (c.login.Equals(compte.login) && (c.password.Equals(compte.password))) { return(RedirectToAction("Index")); } else { ViewBag.message = "Erreur, Login ou mot de passe"; } } //db.Compte.Add(compte); //db.SaveChanges(); } return(View(compte)); }