public IHttpActionResult PutTrainerTable(int id, TrainerTable trainerTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != trainerTable.id) { return(BadRequest()); } db.Entry(trainerTable).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TrainerTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetTrainerTable(int id) { TrainerTable trainerTable = db.TrainerTables.Find(id); if (trainerTable == null) { return(NotFound()); } return(Ok(trainerTable)); }
public IHttpActionResult PostTrainerTable(TrainerTable trainerTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TrainerTables.Add(trainerTable); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = trainerTable.id }, trainerTable)); }
public IHttpActionResult DeleteTrainerTable(int id) { TrainerTable trainerTable = db.TrainerTables.Find(id); if (trainerTable == null) { return(NotFound()); } db.TrainerTables.Remove(trainerTable); db.SaveChanges(); return(Ok(trainerTable)); }