public ActionResult UpdateEPC(UpdateEPCModel updateEPCModel) { var db = DAL.DbContext.Create(); if (updateEPCModel.Id <= 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var studentToUpdate = db.Students.Get(updateEPCModel.Id); if (studentToUpdate != null) { studentToUpdate.Course = db.Courses.Get(studentToUpdate.CourseID); studentToUpdate.College = db.Colleges.Get(studentToUpdate.CollegeID); } if (ModelState.IsValid) { if (EPCValidate(studentToUpdate)) { studentToUpdate.EPC = updateEPCModel.EPC; db.Students.Update(studentToUpdate.Id, studentToUpdate); return(RedirectToAction("Index")); } } return(View(studentToUpdate)); }
public ActionResult UpdateEPC(UpdateEPCModel updateEPCModel) { var db = DAL.DbContext.Create(); if (updateEPCModel.Id <= 0) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var studentToUpdate = db.Students.Get(updateEPCModel.Id); if (studentToUpdate != null) { studentToUpdate.Course = db.Courses.Get(studentToUpdate.CourseID); studentToUpdate.College = db.Colleges.Get(studentToUpdate.CollegeID); } if (ModelState.IsValid) { if (EPCValidate(studentToUpdate)) { studentToUpdate.EPC = updateEPCModel.EPC; db.Students.Update(studentToUpdate.Id, studentToUpdate); return RedirectToAction("Index"); } } return View (studentToUpdate); }