Example #1
0
 public void Eliminar()
 {
     try
     {
         using (var ctx = new TestContex())
         {
             ctx.Entry(this).State = System.Data.Entity.EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
        public List <Curso> Listar()
        {
            var cursos = new List <Curso>();

            try
            {
                using (var ctx = new TestContex())
                {
                    cursos = ctx.Curso.ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(cursos);
        }
Example #3
0
        public List <Alumno> Listar()
        {
            var alumnos = new List <Alumno>();

            try
            {
                using (var ctx = new TestContex())
                {
                    alumnos = ctx.Alumno.ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(alumnos);
        }
Example #4
0
        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);
        }
Example #5
0
        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;
            }
        }