public IHttpActionResult PutEnrollment(int id, Enrollment enrollment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != enrollment.EnrollmentID) { return(BadRequest()); } db.Entry(enrollment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EnrollmentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutCourse(int id, Course course) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != course.CourseID) { return(BadRequest()); } db.Entry(course).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CourseExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "ID,LastName,FirstMidName,EnrollmentDate")] Student student) { if (ModelState.IsValid) { db.Entry(student).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Edit([Bind(Include = "CourseID,Title,Credits")] Course course) { if (ModelState.IsValid) { db.Entry(course).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(course)); }
public ActionResult Edit([Bind(Include = "EnrollmentID,CourseID,StudentID,Grade")] Enrollment enrollment) { if (ModelState.IsValid) { db.Entry(enrollment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Title", enrollment.CourseID); ViewBag.StudentID = new SelectList(db.Students, "ID", "LastName", enrollment.StudentID); return(View(enrollment)); }