public static Alumno GetAlumno(UsuarioAnonimo ua) { using (db = new TP_20191CEntities()) { return((from a in db.Alumnoes where a.Email == ua.InputEmail && a.Password == ua.InputPassword select a).FirstOrDefault()); } }
public static Profesor GetProfesor(UsuarioAnonimo ua) { using (db = new TP_20191CEntities()) { return((from p in db.Profesors where p.Email == ua.InputEmail && p.Password == ua.InputPassword select p).FirstOrDefault()); } }
public static Alumno CheckAlumno(UsuarioAnonimo ua) { using (db) { var userDetails = db.Alumnoes.Where(u => u.Email == ua.InputEmail && u.Password == ua.InputPassword).FirstOrDefault(); //return (userDetails != null) ? true : false; return(userDetails); } }
public ActionResult Ingresar(UsuarioAnonimo ua) { if (ModelState.IsValid) { if (ua.IsProfesor == true) { Profesor profesorDetails = CheckUserToLog.GetProfesor(ua); if (profesorDetails == null) { ua.LogError = "Datos invalidos, intente nuevamente."; } else { Session["UserSession"] = (profesorDetails.IdProfesor).ToString(); Session["UserName"] = profesorDetails.Nombre + " " + profesorDetails.Apellido; Session["UserType"] = "Profesor"; return(Redirect("/Home/Inicio")); } } else { Alumno alumnoDetails = CheckUserToLog.GetAlumno(ua); if (alumnoDetails == null) { ua.LogError = "Datos invalidos, intente nuevamente."; } else { Session["UserSession"] = (alumnoDetails.IdAlumno).ToString(); Session["UserName"] = alumnoDetails.Nombre + " " + alumnoDetails.Apellido; Session["UserType"] = "Alumno"; return(Redirect("/Home/Inicio")); } } } return(View(ua)); }