예제 #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;
        }
예제 #2
0
        public List <Curso> Todos(int Alumno_id = 0)
        {
            var cursos = new List <Curso>();

            try
            {
                using (var ctx = new UdemyContext())
                {
                    if (Alumno_id > 0)
                    {
                        var cursos_tomados = ctx.AlumnoCurso.Where(x => x.Alumno_id == Alumno_id)
                                             .Select(x => x.Curso_id)
                                             .ToList();

                        cursos = ctx.Curso.Where(x => !cursos_tomados.Contains(x.id_curso)).ToList();
                    }
                    else
                    {
                        cursos = ctx.Curso.ToList();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(cursos);
        }
예제 #3
0
 public void Eliminar()
 {
     try
     {
         using (var ctx = new UdemyContext())
         {
             ctx.Entry(this).State = EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
     catch (Exception E)
     {
         throw;
     }
 }
예제 #4
0
        public List <TAlumno> listar()
        {
            var alumnos = new List <TAlumno>();

            try
            {
                using (var ctx = new UdemyContext())
                {
                    alumnos = ctx.TAlumno.ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(alumnos);
        }
예제 #5
0
        public List <login> listaFiltrada(login user)
        {
            var alumnos = new List <login>();

            try
            {
                using (var ctx = new UdemyContext())
                {
                    alumnos = ctx.login.Where(x => x.ceduser == user.ceduser && x.passuser == user.passuser).ToList();
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(alumnos);
        }
예제 #6
0
        public login usuarioLogin(login user)
        {
            var elusuario = new login();

            try
            {
                using (var ctx = new UdemyContext())
                {
                    elusuario = ctx.login.Where(x => x.ceduser == user.ceduser && x.passuser == user.passuser).SingleOrDefault();
                }
            }
            catch (Exception)
            {
                throw;
            }


            return(elusuario);
        }
예제 #7
0
        public List <AlumnoCurso> Listar(int Alumno_id)
        {
            var alumnocursos = new List <AlumnoCurso>();

            try
            {
                using (var ctx = new UdemyContext())
                {
                    alumnocursos = ctx.AlumnoCurso.Include("Curso")
                                   .Where(x => x.Alumno_id == Alumno_id)
                                   .ToList();
                }
            }
            catch (Exception E)
            {
                throw;
            }

            return(alumnocursos);
        }
예제 #8
0
        public ResponseModel Guardar()
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new UdemyContext())
                {
                    ctx.Entry(this).State = EntityState.Added;

                    rm.SetResponse(true);
                    ctx.SaveChanges();
                }
            }
            catch (Exception E)
            {
                throw;
            }

            return(rm);
        }
예제 #9
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);
        }