public IHttpActionResult PostTrainerPersonalDetail(TrainerPersonalDetail trainerpersonaldetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TrainerPersonalDetails.Add(trainerpersonaldetail); try { db.SaveChanges(); } catch (DbUpdateException) { if (TrainerPersonalDetailExists(trainerpersonaldetail.TrainerPersonalId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = trainerpersonaldetail.TrainerPersonalId }, trainerpersonaldetail)); }
// PUT api/TrainerPersonal/5 public IHttpActionResult PutTrainerPersonalDetail(int id, TrainerPersonalDetail trainerpersonaldetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != trainerpersonaldetail.TrainerPersonalId) { return(BadRequest()); } db.Entry(trainerpersonaldetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TrainerPersonalDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetTrainerPersonalDetail(int id) { TrainerPersonalDetail trainerpersonaldetail = db.TrainerPersonalDetails.Find(id); if (trainerpersonaldetail == null) { return(NotFound()); } return(Ok(trainerpersonaldetail)); }
public IHttpActionResult DeleteTrainerPersonalDetail(int id) { TrainerPersonalDetail trainerpersonaldetail = db.TrainerPersonalDetails.Find(id); if (trainerpersonaldetail == null) { return(NotFound()); } db.TrainerPersonalDetails.Remove(trainerpersonaldetail); db.SaveChanges(); return(Ok(trainerpersonaldetail)); }