// PUT api/Message/5 public IHttpActionResult PutMessage(int id, Message message) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != message.messageId) { return BadRequest(); } db.Entry(message).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MessageExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostMessage(Message message) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Messages.Add(message); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = message.messageId }, message); }