public ActionResult Login(string email, string password) { if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password)) { FinalProyectWebDB db = new FinalProyectWebDB(); var userAdmin = db.AdminsTable.FirstOrDefault(e => e.Email == email && e.Password == password); var user = db.UserTable.FirstOrDefault(e => e.Email == email && e.Password == password); var userSocio = db.SociosClubTableSet.FirstOrDefault(e => e.Email == email && e.Password == password); if (userAdmin != null) { FormsAuthentication.SetAuthCookie(userAdmin.Email, true); return(RedirectToAction("Index", "UserTables")); } else if (user != null) { FormsAuthentication.SetAuthCookie(user.Email, true); return(RedirectToAction("Index", "UserView")); } else if (userSocio != null) { FormsAuthentication.SetAuthCookie(userSocio.Email, true); return(RedirectToAction("Index2", "UserView")); } else { return(Index("Datos erroneos.")); } } else { return(Index("Debe llenar los Campos")); } }
// GET: Login public ActionResult Index(string message = "") { if (User.Identity.IsAuthenticated) { FinalProyectWebDB db = new FinalProyectWebDB(); var userAdmin = db.AdminsTable.FirstOrDefault(e => e.Email == User.Identity.Name); var user = db.UserTable.FirstOrDefault(e => e.Email == User.Identity.Name); var userSocio = db.SociosClubTableSet.FirstOrDefault(e => e.Email == User.Identity.Name); if (userAdmin != null) { return(RedirectToAction("Index", "UserTables")); } else if (user != null) { return(RedirectToAction("Index", "UserView")); } else if (userSocio != null) { return(RedirectToAction("Index2", "UserView")); } return(View(message)); } else { ViewBag.Message = message; return(View(message)); } }