public void Eliminar() { try { using (var ctx = new TestContex()) { ctx.Entry(this).State = System.Data.Entity.EntityState.Deleted; ctx.SaveChanges(); } } catch (Exception) { throw; } }
public List <Curso> Listar() { var cursos = new List <Curso>(); try { using (var ctx = new TestContex()) { cursos = ctx.Curso.ToList(); } } catch (Exception) { throw; } return(cursos); }
public List <Alumno> Listar() { var alumnos = new List <Alumno>(); try { using (var ctx = new TestContex()) { alumnos = ctx.Alumno.ToList(); } } catch (Exception) { throw; } return(alumnos); }
public Curso obtener(int id) { var Cursos = new Curso(); try { using (var ctx = new TestContex()) { Cursos = ctx.Curso.Include("AlumnoCurso") .Include("AlumnoCurso.Alumno") .Where(x => x.id == id) .SingleOrDefault(); } } catch (Exception) { throw; } return(Cursos); }
public void Guardar() { try { using (var ctx = new TestContex()) { if (this.id > 0) { ctx.Entry(this).State = System.Data.Entity.EntityState.Modified; } else { ctx.Entry(this).State = System.Data.Entity.EntityState.Added; } ctx.SaveChanges(); } } catch (Exception) { throw; } }