public IHttpActionResult PutcommentOfProduct(int id, commentOfProduct commentOfProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != commentOfProduct.comment_id) { return(BadRequest()); } db.Entry(commentOfProduct).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!commentOfProductExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetcommentOfProduct(int id) { commentOfProduct commentOfProduct = db.commentOfProducts.Find(id); if (commentOfProduct == null) { return(NotFound()); } return(Ok(commentOfProduct)); }
public IHttpActionResult PostcommentOfProduct(commentOfProduct commentOfProduct) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } commentOfProduct.createdAt = DateTime.Now; db.commentOfProducts.Add(commentOfProduct); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = commentOfProduct.comment_id }, commentOfProduct)); }
public IHttpActionResult DeletecommentOfProduct(int id) { commentOfProduct commentOfProduct = db.commentOfProducts.Find(id); if (commentOfProduct == null) { return(NotFound()); } db.commentOfProducts.Remove(commentOfProduct); db.SaveChanges(); return(Ok(commentOfProduct)); }