예제 #1
0
        public List <Alumno> GetAll()
        {
            List <Alumno> getRegs = new List <Alumno>();

            try
            {
                using (var ctx = new DBCursoContext())
                {
                    getRegs = ctx.Alumno.ToList();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(getRegs);
        }
예제 #2
0
 public void Delected()
 {
     try
     {
         using (var ctx = new DBCursoContext())
         {
             if (this.IdAlumno > 0)
             {
                 ctx.Entry(this).State = EntityState.Deleted;
             }
             ctx.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }
예제 #3
0
        public Alumno GetById(int id)
        {
            Alumno alum = new Alumno();

            try
            {
                using (var ctx = new DBCursoContext())
                {
                    alum = ctx.Alumno.Include("AlumnoCurso")
                           .Include("AlumnoCurso.Cuso")
                           .Where(x => x.IdAlumno == id).SingleOrDefault();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return(alum);
        }
예제 #4
0
 public void Salve()
 {
     try
     {
         using (var ctx = new DBCursoContext())
         {
             if (this.IdAlumno > 0)
             {
                 ctx.Entry(this).State = EntityState.Modified;
             }
             else
             {
                 ctx.Entry(this).State = EntityState.Added;
             }
             ctx.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }