Esempio n. 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;
     }
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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;
            }
        }