Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult AddReview(string ReviewText, int ProdID)
- {
- var review = new Review();
- review.ReviewDesc = ReviewText;
- review.ID = ProdID;
- review.ReviewDate = DateTime.Now.Date;
- //==== Get User ID =====
- review.UserID = User.Identity.GetUserId();
- //======
- db.Reviews.Add(review);
- db.SaveChanges();
- var product = db.products.Find(ProdID);
- var rev = db.Reviews.Where(x => x.ID == ProdID);
- return View("Details", product);
- }
- /////////////////////////////////////
- public class ReviewProducts
- {
- ApplicationDbContext db = new ApplicationDbContext();
- public IEnumerable<Review> GetReviewByID(int prodId)
- {
- var reviews = db.Reviews.Where(x => x.ID == prodId);
- return reviews.AsEnumerable().OrderByDescending(x => x.ID);
- }
- }
- /////////////////////////
- @using (Html.BeginForm("AddReview", "Home"))
- {
- <input type="text" name="ReviewText" />
- <input type="hidden" name="ProdID" value="@Model.ID">
- <input type="submit" value="Post Review" />
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement