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); }