예제 #1
0
        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));
        }
예제 #2
0
        public IHttpActionResult GetcommentOfProduct(int id)
        {
            commentOfProduct commentOfProduct = db.commentOfProducts.Find(id);

            if (commentOfProduct == null)
            {
                return(NotFound());
            }

            return(Ok(commentOfProduct));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }