public ActionResult Edit([Bind(Include = "ID,Name,Start,End,StateID,Link,EntityTypeID")] Project proyecto) { if (ModelState.IsValid) { if (!ExisteProyecto(proyecto)) { db.Projects.Add(proyecto); } var temp = db.Projects.Find(proyecto.ID); if (temp != null) { db.Entry(temp).Property(p => p.Name).CurrentValue = proyecto.Name; db.Entry(temp).Property(p => p.Start).CurrentValue = proyecto.Start; db.Entry(temp).Property(p => p.End).CurrentValue = proyecto.End; } db.SaveChanges(); TempData[TempDataMessageKeySuccess] = "Proyecto editado correctamente."; return(RedirectToAction("Index")); } return(RedirectToAction("Edit")); }
public ActionResult Edit([Bind(Include = "ID,Name,Code,TheoreticalHours,Block,External,PracticeHours,Credits")] Course curso, String Name, String Code) { if (curso.Name != Name) { if (existeCursoPorNombre(curso.Name)) { TempData[TempDataMessageKeyError] = "Es posible que exista un curso con el mismo nombre. Por Favor intente de nuevo."; return(RedirectToAction("Edit")); } } if (curso.Code != Code) { if (existeCurso(curso.Code)) { TempData[TempDataMessageKeyError] = "Es posible que exista un curso con el mismo codigo. Por Favor intente de nuevo."; return(RedirectToAction("Edit")); } } if (ModelState.IsValid) { db.Entry(curso).State = EntityState.Modified; db.SaveChanges(); TempData[TempDataMessageKeyError] = "El registro ha sido editado correctamente."; return(RedirectToAction("Index")); } return(View(curso)); }
public void EditGroup(int pIdGroup, int pIdProfessor) { Group vGroup = gvDatabase.Groups.Find(pIdGroup); vGroup.ProfessorID = pIdProfessor; gvDatabase.Entry(vGroup).State = EntityState.Modified; gvDatabase.SaveChanges(); }
public ActionResult Edit(PlazaEditViewModel viewModel) { if (ModelState.IsValid) { var vPlaza = db.Plazas.Find(viewModel.ID); vPlaza.Code = viewModel.Code; vPlaza.PlazaType = viewModel.PlazaType; vPlaza.TimeType = viewModel.TimeType; vPlaza.TotalHours = viewModel.TotalHours; vPlaza.EffectiveTime = viewModel.EffectiveTime; db.Entry(vPlaza).State = EntityState.Modified; db.SaveChanges(); TempData[TempDataMessageKeySuccess] = "Plaza editada exitosamente"; return(RedirectToAction("Index")); } return(View(viewModel)); }
public ActionResult Edit([Bind(Include = "ID,Description,Level")] AcademicBlock bloqueAcademico) { if (ModelState.IsValid) { db.Entry(bloqueAcademico).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bloqueAcademico)); }
public ActionResult Edit([Bind(Include = "ID,SedeID,Code,Capacity,Active")] Classroom aula) { if (ModelState.IsValid) { if (db.Classrooms.Where(p => p.Code == aula.Code && p.SedeID == aula.SedeID).Count() == 0) { aula.SedeID = Convert.ToInt32(Request.Form["Sedes"].ToString()); db.Entry(aula).State = EntityState.Modified; db.SaveChanges(); TempData[TempDataMessageKeySuccess] = "Aula código: " + aula.Code + " editada correctamente"; return(RedirectToAction("Index")); } else { TempData[TempDataMessageKey] = "Esta sede ya cuenta con un aula con el código provisto. Por Favor intente de nuevo." + aula.Code; } } ViewBag.SedeID = new SelectList(db.Sedes, "ID", "Name", aula.SedeID); return(View(aula)); }
public ActionResult Edit([Bind(Include = "ID,Name")] Sede sede) { if (ModelState.IsValid) { db.Entry(sede).State = EntityState.Modified; db.SaveChanges(); TempData[TempDataMessageKeySuccess] = "Sede editada correctamente."; return(RedirectToAction("Index")); } return(View(sede)); }
public ActionResult Edit([Bind(Include = "ID,Name,Start,End,StateID,EntityTypeID")] Commission commission) { if (!ExisteComision(commission)) { AgregarComision(commission); } if (ModelState.IsValid) { var temp = db.Commissions.Find(commission.ID); if (temp != null) { db.Entry(temp).Property(c => c.Name).CurrentValue = commission.Name; db.Entry(temp).Property(c => c.Start).CurrentValue = commission.Start; db.Entry(temp).Property(c => c.End).CurrentValue = commission.End; } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(commission)); }
public void modificarCursoBloquePlan(int idBloqueXplan, int idBloque) { var vBloqueXPlanXCurso = gvDatabase.BlocksXPlansXCourses.SingleOrDefault(bloqueXplanXcurso => bloqueXplanXcurso.BlockXPlanID == idBloqueXplan); if (vBloqueXPlanXCurso != null) { gvDatabase.Entry(vBloqueXPlanXCurso).Property(bloqueXplanXcurso => bloqueXplanXcurso.BlockXPlanID).CurrentValue = idBloque; gvDatabase.SaveChanges(); } else { return; } }
public ActionResult ResolveCommissions(AlertViewModel viewModel) { if (ModelState.IsValid) { for (int i = 0; i < viewModel.Commissions.Count; i++) { var commission = db.Commissions.Find(viewModel.Commissions[i].ID); db.Entry(commission).Property(c => c.StateID).CurrentValue = 2; db.SaveChanges(); if (commission.CommissionsXProfessors.Count > 0) { var commissionProfessors = commission.CommissionsXProfessors.ToList(); foreach (var commissionProfessor in commissionProfessors) { db.CommissionsXProfessors.Remove(commissionProfessor); db.SaveChanges(); } } } } return(RedirectToAction("Index")); }