public ActionResult Review([Bind(Include = "ProductReviewID, ProductID, ReviewerName, " +
                                                   "ReviewDate, EmailAddress, Rating, Comments, CommentsModifiedDate, Product ")] ProductReview review)
        {
            string id = review.ProductID.ToString();

            ViewBag.ProductID = id;
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }

            if (ModelState.IsValid)
            {
                review.ProductID    = Convert.ToInt32(id);
                review.ReviewDate   = DateTime.Now;
                review.ModifiedDate = review.ReviewDate;
                review.Product      = db.Products.Where(p => p.ProductID.ToString() == id).FirstOrDefault();

                db.ProductReviews.Add(review);
                db.SaveChanges();

                return(Redirect("/Home/Details/" + id));
            }

            return(View(review));
        }
Beispiel #2
0
 public bool Save()
 {
     return(_context.SaveChanges() >= 0);
 }