Example #1
0
 protected void Update(Curso entity)
 {
     using (var context = new AcademiaContext())
     {
         if (isRepeated(entity))
         {
             throw new Exception("Repeated entity");
         }
         entity.Materia.Plan = null;
         var local = context.Set <Materia>()
                     .Local
                     .FirstOrDefault(f => f.ID == entity.Materia.ID);
         if (local != null)
         {
             context.Entry(local).State = EntityState.Detached;
         }
         context.Entry(entity.Materia).State = System.Data.Entity.EntityState.Unchanged;
         entity          = context.Curso.Attach(entity);
         entity.Comision = context.Comision.Attach(entity.Comision);
         entity.Materia  = context.Materia.Attach(entity.Materia);
         var entry = context.Entry(entity); // Gets the entry for entity inside context
         entry.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #2
0
 protected void Update(Comision comi)
 {
     using (var context = new AcademiaContext())
     {
         var comision = context.Comisiones.Find(comi.ID);
         context.Entry(comision).CurrentValues.SetValues(comi);
         context.SaveChanges();
     }
 }
Example #3
0
 protected void Update(Plan plan)
 {
     using (var context = new AcademiaContext())
     {
         var planEntity = context.Planes.Find(plan.ID);
         context.Entry(plan).CurrentValues.SetValues(plan);
         context.SaveChanges();
     }
 }
Example #4
0
 protected void Update(Especialidad esp)
 {
     using (var context = new AcademiaContext())
     {
         var especialidad = context.Especialidades.Find(esp.ID);
         context.Entry(especialidad).CurrentValues.SetValues(esp);
         context.SaveChanges();
     }
 }
Example #5
0
 protected void Update(Persona psr)
 {
     using (var context = new AcademiaContext())
     {
         var alumno = context.Personas.Find(psr.ID);
         context.Entry(alumno).CurrentValues.SetValues(psr);
         context.SaveChanges();
     }
 }
Example #6
0
 protected void Update(Curso cur)
 {
     using (var context = new AcademiaContext())
     {
         var curso = context.Cursos.Find(cur.ID);
         context.Entry(curso).CurrentValues.SetValues(cur);
         context.SaveChanges();
     }
 }
Example #7
0
 protected void Update(Persona entity)
 {
     using (var context = new AcademiaContext())
     {
         entity = context.Persona.Attach(entity);
         var entry = context.Entry(entity); // Gets the entry for entity inside context
         entry.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #8
0
 protected void Update(Plan entity)
 {
     using (var context = new AcademiaContext())
     {
         entity = context.Plan.Attach(entity);
         entity.Especialidad = context.Especialidad.Attach(entity.Especialidad);
         var entry = context.Entry(entity); // Gets the entry for entity inside context
         entry.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #9
0
 protected void Update(DocenteCurso entity)
 {
     using (var context = new AcademiaContext())
     {
         if (isRepeated(entity))
         {
             throw new Exception("Repeated entity");
         }
         entity         = context.DocenteCurso.Attach(entity);
         entity.Docente = context.Persona.Attach(entity.Docente);
         entity.Curso   = context.Curso.Attach(entity.Curso);
         var entry = context.Entry(entity); // Gets the entry for entity inside context
         entry.State = EntityState.Modified;
         context.SaveChanges();
     }
 }