Exemplo n.º 1
0
        public Alumnos Eliminar()
        {
            var alumno = new Alumnos();

            try
            {
                using (var ctx = new TestContext())
                {
                    ctx.Entry(this).State = EntityState.Deleted;
                    ctx.SaveChanges();
                }
            }
            catch (Exception e)
            {
                e.ToString();
                throw;
            }

            return(alumno);
        }
Exemplo n.º 2
0
        //public Alumnos Obtener(int id)
        //{
        //    var alumno = new Alumnos();
        //    try
        //    {
        //        using (var context = new BaseDeDatosContext())
        //        {
        //            alumno = context.Alumnos
        //                            .Include("Ciudades")
        //                            .Where(x => x.Alumno_Id == id)
        //                            .Single();
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        throw new Exception(e.Message);
        //    }

        //    return alumno;
        //}

        public Alumnos Obtener(int id)
        {
            var alumno = new Alumnos();

            try
            {
                using (var context = new BaseDeDatosContext())
                {
                    alumno = context.Alumnos
                             .Include("Ciudades").Include("Cursos")
                             .Where(x => x.Alumno_Id == id)
                             .Single();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            return(alumno);
        }
Exemplo n.º 3
0
        public Alumnos Obtener(int id)
        {
            var alumno = new Alumnos();

            try
            {
                using (var ctx = new TestContext())
                {
                    alumno = ctx.Alumnos.Include("AlumnoCurso")
                             .Include("AlumnoCurso.Curso")
                             .Where(x => x.idAlumno == id)
                             .SingleOrDefault();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }

            return(alumno);
        }