public IHttpActionResult PutReply(int id, Reply reply) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != reply.ID) { return BadRequest(); } db.Entry(reply).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ReplyExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostReply(Reply reply) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Replies.Add(reply); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = reply.ID }, reply); }