public IHttpActionResult PutCarpoolGroup(int id, CarpoolGroup carpoolGroup) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != carpoolGroup.CarpoolGroupID) { return(BadRequest()); } db.Entry(carpoolGroup).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CarpoolGroupExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCarpoolGroup(int id) { CarpoolGroup carpoolGroup = db.CarpoolGroups.Find(id); if (carpoolGroup == null) { return(NotFound()); } return(Ok(carpoolGroup)); }
public IHttpActionResult PostCarpoolGroup(CarpoolGroup carpoolGroup) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CarpoolGroups.Add(carpoolGroup); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = carpoolGroup.CarpoolGroupID }, carpoolGroup)); }
public IHttpActionResult DeleteCarpoolGroup(int id) { CarpoolGroup carpoolGroup = db.CarpoolGroups.Find(id); if (carpoolGroup == null) { return(NotFound()); } db.CarpoolGroups.Remove(carpoolGroup); db.SaveChanges(); return(Ok(carpoolGroup)); }