public ActionResult DeleteConfirmed(int id) { CollegeDBEF.Models.Students students = db.Students.Find(id); db.Students.Remove(students); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult PutStudents(int id, CollegeDBEF.Models.Students students) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != students.ID) { return(BadRequest()); } db.Entry(students).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StudentsExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "ID,FName,LName,SSN,Address,City,State,Zip,Phone")] CollegeDBEF.Models.Students students) { if (ModelState.IsValid) { db.Entry(students).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(students)); }
public IHttpActionResult GetStudents(int id) { CollegeDBEF.Models.Students students = db.Students.Find(id); if (students == null) { return(NotFound()); } return(Ok(students.FName + " " + students.LName)); }
public ActionResult Create([Bind(Include = "ID,FName,LName,SSN,Address,City,State,ZipCode,Phone")] CollegeDBEF.Models.Students students) { if (ModelState.IsValid) { db.Students.Add(students); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(students)); }
public IHttpActionResult PostStudents(CollegeDBEF.Models.Students students) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Students.Add(students); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = students.ID }, students)); }
// GET: Students/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CollegeDBEF.Models.Students students = db.Students.Find(id); if (students == null) { return(HttpNotFound()); } return(View(students)); }
public IHttpActionResult DeleteStudents(int id) { CollegeDBEF.Models.Students students = db.Students.Find(id); if (students == null) { return(NotFound()); } db.Students.Remove(students); db.SaveChanges(); return(Ok(students)); }