public IHttpActionResult PutAStudent(int id, Students3 aStudentAll) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != aStudentAll.Id) { return(BadRequest()); } db.Entry(aStudentAll).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AStudentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetAStudent(int id) { Students3 aEmployee = db.Students3.Find(id); if (aEmployee == null) { return(NotFound()); } return(Ok(aEmployee)); }
public IHttpActionResult PostAStudent(Students3 aStudentAll) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Students3.Add(aStudentAll); db.SaveChanges(); // return CreatedAtRoute("DefaultApi", new { id = aStudentAll.Id }, aStudentAll); return(RedirectToRoute("Index", "Home")); }
public IHttpActionResult DeleteAStudent(int id) { Students3 aEmployee = db.Students3.Find(id); if (aEmployee == null) { return(NotFound()); } db.Students3.Remove(aEmployee); db.SaveChanges(); return(Ok(aEmployee)); }