Ejemplo n.º 1
0
        public void Guardar()
        {
            // var rm = new ResponseModel();

            var alumnos = new TAlumno();

            try
            {
                using (var ctx = new UdemyContext())
                {
                    if (this.id > 0)
                    {
                        ctx.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        ctx.Entry(this).State = EntityState.Added;
                    }
                    //  rm.SetResponse(true);
                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }

            //return rm;
        }
Ejemplo n.º 2
0
        public TAlumno obtener(int id)
        {
            var alumnos = new TAlumno();

            try
            {
                using (var ctx = new UdemyContext())
                {
                    alumnos = ctx.TAlumno
                              .Include("AlumnoCurso")
                              .Include("AlumnoCurso.Curso")
                              .Where(x => x.id == id)
                              .SingleOrDefault();
                }
            }
            catch (Exception E)
            {
                throw;
            }

            return(alumnos);
        }