public void Guardar() { // var rm = new ResponseModel(); var alumnos = new TAlumno(); try { using (var ctx = new UdemyContext()) { if (this.id > 0) { ctx.Entry(this).State = EntityState.Modified; } else { ctx.Entry(this).State = EntityState.Added; } // rm.SetResponse(true); ctx.SaveChanges(); } } catch (Exception) { throw; } //return rm; }
public List <Curso> Todos(int Alumno_id = 0) { var cursos = new List <Curso>(); try { using (var ctx = new UdemyContext()) { if (Alumno_id > 0) { var cursos_tomados = ctx.AlumnoCurso.Where(x => x.Alumno_id == Alumno_id) .Select(x => x.Curso_id) .ToList(); cursos = ctx.Curso.Where(x => !cursos_tomados.Contains(x.id_curso)).ToList(); } else { cursos = ctx.Curso.ToList(); } } } catch (Exception) { throw; } return(cursos); }
public void Eliminar() { try { using (var ctx = new UdemyContext()) { ctx.Entry(this).State = EntityState.Deleted; ctx.SaveChanges(); } } catch (Exception E) { throw; } }
public List <TAlumno> listar() { var alumnos = new List <TAlumno>(); try { using (var ctx = new UdemyContext()) { alumnos = ctx.TAlumno.ToList(); } } catch (Exception) { throw; } return(alumnos); }
public List <login> listaFiltrada(login user) { var alumnos = new List <login>(); try { using (var ctx = new UdemyContext()) { alumnos = ctx.login.Where(x => x.ceduser == user.ceduser && x.passuser == user.passuser).ToList(); } } catch (Exception) { throw; } return(alumnos); }
public login usuarioLogin(login user) { var elusuario = new login(); try { using (var ctx = new UdemyContext()) { elusuario = ctx.login.Where(x => x.ceduser == user.ceduser && x.passuser == user.passuser).SingleOrDefault(); } } catch (Exception) { throw; } return(elusuario); }
public List <AlumnoCurso> Listar(int Alumno_id) { var alumnocursos = new List <AlumnoCurso>(); try { using (var ctx = new UdemyContext()) { alumnocursos = ctx.AlumnoCurso.Include("Curso") .Where(x => x.Alumno_id == Alumno_id) .ToList(); } } catch (Exception E) { throw; } return(alumnocursos); }
public ResponseModel Guardar() { var rm = new ResponseModel(); try { using (var ctx = new UdemyContext()) { ctx.Entry(this).State = EntityState.Added; rm.SetResponse(true); ctx.SaveChanges(); } } catch (Exception E) { throw; } return(rm); }
public TAlumno obtener(int id) { var alumnos = new TAlumno(); try { using (var ctx = new UdemyContext()) { alumnos = ctx.TAlumno .Include("AlumnoCurso") .Include("AlumnoCurso.Curso") .Where(x => x.id == id) .SingleOrDefault(); } } catch (Exception E) { throw; } return(alumnos); }