コード例 #1
0
        public ActionResult EditarMateria(MateriaViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (SchoolAppEntities db = new SchoolAppEntities())
                    {
                        var oTabla = db.Materias.Find(model.IdMaterias);
                        oTabla.ID_curso = model.IdCurso;
                        oTabla.Profesor = model.Profesor;
                        oTabla.Materia  = model.Materia;
                        oTabla.Horario  = model.Horario;
                        oTabla.Duracion = model.Duracion;

                        db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    return(Redirect("~/Materia/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
        public ActionResult EditarEstudiante(EstudianteViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (SchoolAppEntities db = new SchoolAppEntities())
                    {
                        var oTabla = db.Estudiantes.Find(model.IdEstudiantes);
                        oTabla.ID_curso  = model.IdCurso;
                        oTabla.Nombre    = model.Nombre;
                        oTabla.Apellido  = model.Apellido;
                        oTabla.Sexo      = model.Sexo;
                        oTabla.Edad      = model.Edad;
                        oTabla.Codigo    = model.Codigo;
                        oTabla.Telefono  = model.Telefono;
                        oTabla.Direccion = model.Direccion;



                        db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    return(Redirect("~/Estudiante/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #3
0
ファイル: CursoController.cs プロジェクト: zaizo01/SchoolApp
        public ActionResult Editar(CursoViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (SchoolAppEntities db = new SchoolAppEntities())
                    {
                        var oTabla = db.Curso.Find(model.IdCurso);
                        oTabla.Grado               = model.Grado;
                        oTabla.Seccion             = model.Seccion;
                        oTabla.Cant_de_Estudiantes = model.CantDeEstudiantes;
                        oTabla.Profesor_encargado  = model.ProfesorEncargado;

                        db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                    return(Redirect("~/Curso/"));
                }
                return(View(model));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "StudentId,StudentName")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "CourseId,CourseName,CourseDescription")] Cours course)
 {
     if (ModelState.IsValid)
     {
         db.Entry(course).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(course));
 }