// GET: Login public ActionResult Index() { ExamenFinalWebDataBase db = new ExamenFinalWebDataBase(); if (User.Identity.IsAuthenticated) { var userAdmin = db.AdminTable.FirstOrDefault(e => e.NombreAdmin == User.Identity.Name); var userContacto = db.ContactTable.FirstOrDefault(e => e.NombreContacto == User.Identity.Name); if (userAdmin != null) { return(RedirectToAction("Index", "ContactoVisitaTablas")); } else if (userContacto != null) { return(RedirectToAction("Index2", "ContactoVisitaTablas")); } else { return(View()); } } else { return(View()); } }
public ActionResult Index(string username, string password) { if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { ExamenFinalWebDataBase db = new ExamenFinalWebDataBase(); var userAdmin = db.AdminTable.FirstOrDefault(e => e.NombreDeUsuarioAdmin == username && e.ContraseñaAdmin == password); var userContacto = db.ContactTable.FirstOrDefault(e => e.NombreDeUsuarioContacto == username && e.DocumentoDeIdentidad == password); if (userAdmin != null) { FormsAuthentication.SetAuthCookie(userAdmin.NombreAdmin, true); return(RedirectToAction("Index", "ContactoVisitaTablas")); } else if (userContacto != null) { FormsAuthentication.SetAuthCookie(userContacto.NombreContacto, true); return(RedirectToAction("Index2", "ContactoVisitaTablas")); } } else { } return(View()); }