// POST: api/CommittedPlayers public IHttpActionResult Post(CommittedPlayer committedPlayer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } recruitsDbContext.CommittedPlayers.Add(committedPlayer); recruitsDbContext.SaveChanges(); return(StatusCode(HttpStatusCode.Created)); }
// PUT: api/CommittedPlayers/5 public IHttpActionResult Put(int id, [FromBody] CommittedPlayer committedplayer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = recruitsDbContext.CommittedPlayers.FirstOrDefault(q => q.Id == id); if (entity == null) { return(BadRequest("No record found matching this ID.")); } entity.FirstName = committedplayer.FirstName; entity.LastName = committedplayer.LastName; entity.Email = committedplayer.Email; entity.PhoneNumber = committedplayer.PhoneNumber; entity.JerseyNumber = committedplayer.JerseyNumber; entity.CommitmentDate = committedplayer.CommitmentDate; recruitsDbContext.SaveChanges(); return(Ok("Record updated successfully.")); }