static async Task <Profesores> ComprobarInicioSesion(Usuario usuario, BDSAEEContext _context) { Profesores profesor = await _context.Profesores. Where(P => P.Cedula.Equals(usuario.Profesor.Cedula) && P.Contrasenia.Equals(usuario.Profesor.Contrasenia)). FirstOrDefaultAsync(); return(profesor); }
private async void VerificarNotificaciones(object objetc) { using (var scope = serviceProvider.CreateScope()) { BDSAEEContext context = scope.ServiceProvider.GetRequiredService <BDSAEEContext>(); List <NotificacionesCorreo> notificaciones = await context.NotificacionesCorreo.Include(n => n.IdAsignacionNavigation).ToListAsync(); DateTime fechaAsignacion; int diasAnticipacion; Profesores profesor; Cursos curso; Grupos grupo; foreach (NotificacionesCorreo notificacion in notificaciones) { fechaAsignacion = notificacion.IdAsignacionNavigation.Fecha; diasAnticipacion = notificacion.DiasAnticipacion; if (fechaAsignacion.AddDays(diasAnticipacion * -1).Date.Equals(DateTime.Today.Date)) { profesor = await context.Profesores.FindAsync(notificacion.IdAsignacionNavigation.Profesor); grupo = await context.Grupos.FindAsync(notificacion.IdAsignacionNavigation.Grupo); curso = await context.Cursos.FindAsync(notificacion.IdAsignacionNavigation.Curso); new CorreoElectronico(notificacion.IdAsignacionNavigation, profesor, curso, grupo).Enviar(); context.Remove(notificacion); try { await context.SaveChangesAsync(); } catch (Exception) { //Manejar el error } } } } }
public EstudiantesServices(BDSAEEContext context) { this.context = context; }
public Gruposcontroller(BDSAEEContext context) { _context = context; }
public ProfesoresServices(BDSAEEContext context) { _context = context; }
public AsignacionesServices(BDSAEEContext context) { _context = context; }
public EvaluacionesController(BDSAEEContext context) { _context = context; }
public ProfesoresController(BDSAEEContext context) { _context = context; }
public static async Task <Profesores> ComprobarInicioSesion(IHeaderDictionary headers, BDSAEEContext _context) { Usuario usuario = new Usuario() { Profesor = new Profesores() { Cedula = headers["cedula"], Contrasenia = headers["contrasenia"] } }; return(await ComprobarInicioSesion(usuario, _context)); }
//NC: Número de Cédula //CON: Contraseña public async Task <IActionResult> OnGetAsync(string NC, string CON) { string inicioProfesor = Url.Content("~/true"); string inicioEstudiante = Url.Content("~/evaluaciones-estudiante/true"); try { // Clear the existing external cookie await HttpContext .SignOutAsync( CookieAuthenticationDefaults.AuthenticationScheme); } catch { } Profesores profesor; Estudiantes estudiante = null; using (BDSAEEContext context = new BDSAEEContext()) { profesor = await context.Profesores.Where(P => P.Cedula.Equals(NC) && P.Contrasenia.Equals(CON)).FirstOrDefaultAsync(); if (profesor == null) { estudiante = await context.Estudiantes.Where(P => P.Cedula.Equals(NC) && P.Pin.Equals(CON)).FirstOrDefaultAsync(); } } List <Claim> claims = null; if (profesor != null) { claims = new List <Claim> { new Claim(ClaimTypes.Name, profesor.Nombre), new Claim("Ap1", profesor.PrimerApellido), new Claim("Ap2", profesor.SegundoApellido), new Claim("P", true.ToString()), new Claim("E", false.ToString()), (profesor.Administrador) ? new Claim("Rol", "Administrador") : new Claim("Rol", "Profesor"), new Claim("Id", profesor.Id.ToString()) }; } else if (estudiante != null) { claims = new List <Claim> { new Claim(ClaimTypes.Name, estudiante.Nombre), new Claim("Ap1", estudiante.PrimerApellido), new Claim("Ap2", estudiante.SegundoApellido), new Claim("P", false.ToString()), new Claim("E", true.ToString()), new Claim("Rol", "Estudiante"), new Claim("Id", estudiante.Id.ToString()) }; } if (claims != null) { var claimsIdentity = new ClaimsIdentity( claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties { IsPersistent = true, RedirectUri = this.Request.Host.Value }; try { await HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); } catch (Exception ex) { string error = ex.Message; } if (profesor == null) { return(LocalRedirect(inicioEstudiante)); } else { return(LocalRedirect(inicioProfesor)); } } else { return(LocalRedirect("/Inicio-Sesion/true")); } }
public Iniciar_sesionController(BDSAEEContext context) { _context = context; }
public AsignacionesController(BDSAEEContext context) { _context = context; }
public EstudiantesController(BDSAEEContext context) { _context = context; }
public CursosController(BDSAEEContext context) { _context = context; }
public GruposServices(BDSAEEContext context) { this.context = context; }
public CursosGruposServices(BDSAEEContext context) { _context = context; }
public EvaluacionesServices(BDSAEEContext context) { _context = context; }