Exemple #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);
        }
Exemple #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;
     }
 }
Exemple #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);
        }
Exemple #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;
     }
 }