public ActionResult Editar(Tabla5ViewModel model) { try { if (ModelState.IsValid) { using (examenEntities db = new examenEntities()) { var oTabla = db.Horarios.Find(model.Id); oTabla.Nombre = model.Nombre; oTabla.matricula = model.Matricula; oTabla.campus = (int)model.Campus; oTabla.queja = model.Queja; oTabla.Fecha = model.Fecha; oTabla.Estatus = model.Estatus; //Enum.GetName(typeof(/*enum estado estudiante*/), model.Estatus) caso de oTabla.Estatus sea string y model.Estatus un enum //Enum.Parse(typeof(/*enum estado estudiante*/), oTabla.Estatus), model.Estatus) caso de oTabla.Estatus sea enum y model.Estatus un string db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(Redirect("/Horarios/")); } return(View()); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Editar(int Id) { Tabla5ViewModel model = new Tabla5ViewModel(); using (examenEntities db = new examenEntities()) { var oTabla = db.Horarios.Find(Id); model.Nombre = oTabla.Nombre; model.Matricula = oTabla.matricula; model.Campus = (Campus)oTabla.campus; model.Queja = oTabla.queja; model.Fecha = oTabla.Fecha; model.Estatus = oTabla.Estatus; model.Id = oTabla.Id; } return(View(model)); }