public HttpResponseMessage Post(Review review)
 {
     if (ModelState.IsValid)
     {
         if (review.Id == 0)
         {
             _db.Reviews.Add(review);
             _db.SaveChanges();
             return Request.CreateResponse(HttpStatusCode.Created, review);
         }
         else
         {
             var original = _db.Reviews.Find(review.Id);
             original.Image = review.Image;
             original.ProductName = review.ProductName;
             original.ProductReview = review.ProductReview;
             _db.SaveChanges();
             return Request.CreateResponse(HttpStatusCode.OK, review);
         }
     }
     return Request.CreateErrorResponse(HttpStatusCode.BadRequest, this.ModelState);
 }
Ejemplo n.º 2
0
 public void EditReview(Review review)
 {
     var original = this.FindReview(review.Id);
     original.ProductName = review.ProductName;
 }
Ejemplo n.º 3
0
 public void CreateReview(Review review)
 {
     _repo.Add<Review>(review);
     _repo.SaveChanges();
 }