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