public IHttpActionResult PutComments(int id, Comments comments) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != comments.ID) { return BadRequest(); } db.Entry(comments).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CommentsExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostComments(Comments comments) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Comments.Add(comments); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = comments.ID }, comments); }