public ResponseModel Guardar() { var rm = new ResponseModel(); try { using (var cn = new BDCursos()) { if (this.id > 0) { cn.Entry(this).State = EntityState.Modified; } else { cn.Entry(this).State = EntityState.Added; } rm.SetResoponse(true); cn.SaveChanges(); } } catch (Exception) { throw; } return(rm); }
public List <Curso> Todos(int IdAlumno = 0) { var cursos = new List <Curso>(); try { using (var cn = new BDCursos()) { if (IdAlumno > 0) { var cusos_actuales = cn.AlumnoCurso.Where(x => x.Alumno_id == IdAlumno) .Select(x => x.Curso_id).ToList(); cursos = cn.Curso.Where(x => !cusos_actuales.Contains(x.id)).ToList(); } else { cursos = cn.Curso.ToList(); } var lista = cn.Curso.ToList(); cursos = lista; } } catch (Exception) { throw; } return(cursos); }
public void Eliminar() { try { using (var cn = new BDCursos()) { cn.Entry(this).State = EntityState.Deleted; cn.SaveChanges(); //sin los save changes los cambios no quedarán confirmados asi que CUIDADITO WASAWSKY } } catch (Exception) { throw; } }
public List <Alumno> Listar() { var alumno = new List <Alumno>(); try { using (var cn = new BDCursos()) { alumno = cn.Alumno.ToList(); } } catch (Exception) { throw; } return(alumno); }
public List <Curso> Listar() { var cursos = new List <Curso>(); try { using (var cn = new BDCursos()) { var lista = cn.Curso.ToList(); cursos = lista; } } catch (Exception) { throw; } return(cursos); }
public Alumno Obtener(int id) { var alumno = new Alumno(); try { using (var cn = new BDCursos()) { alumno = cn.Alumno.Include("AlumnoCurso").Include("AlumnoCurso.Curso").Where(x => x.id == id).SingleOrDefault(); } } catch (Exception) { throw; } return(alumno); }
public List <AlumnoCurso> Listar(int Alumno_Id) { var alumnocursos = new List <AlumnoCurso>(); try { using (var cn = new BDCursos()) { alumnocursos = cn.AlumnoCurso.Include("Curso") .Where(x => x.Alumno_id == Alumno_Id) .ToList(); } } catch { throw; } return(alumnocursos); }