Example #1
0
        public ActionResult LoginPaciente(string email, string password)
        {
            if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
            {
                ProgramaHelperEntities db = new ProgramaHelperEntities();
                var user = db.RegistroPaciente.FirstOrDefault(e => e.CorreoPaciente == email && e.ContraseñaPaciente == password);



                if (user != null)
                {
                    FormsAuthentication.SetAuthCookie(user.CorreoPaciente, true);
                    //IMPORTANTE PROBAR       HttpContext.Session.Add("correo", user.CorreoPaciente);
                    Session["correo"] = user.CorreoPaciente;

                    //Esto te ayuda guardar el dato que almacenaste
                    //Session["contrasena"] = user.ContraseñaPaciente;

                    return(RedirectToAction("Index", "MenuPacientes"));
                }
                else
                {
                    return(RedirectToAction("LoginPaciente", new { message = "Usuario o contraseña incorrectos" }));
                }
            }
            else
            {
                return(RedirectToAction("LoginPaciente", new { message = "Llena los campos para poder iniciar sesion" }));
            }
        }