Parent View:
@Html.Action("SetReview", "Review", new {sellerId = Model.SellerId})
[HttpGet]
public ActionResult SetReview(string sellerId)
{
return PartialView("_Review", new Finder.Models.Review()
{
SellerId = sellerId
});
}
This is the part where the Id is not getting passed
[HttpPost]
public ActionResult SetReview(Finder.Models.Review review)
{
var review2 = new Review()
{
PersonId = User.Identity.GetUserId(),
SellerId = review.SellerId,
Rating = review.Rating,
IsAnonymous = review.IsAnonymous,
CreatedOn = DateTime.UtcNow,
Content = review.Content,
};
DbContext.Reviews.Add(review2);
DbContext.SaveChanges();
return Json(new { status = "true", msg = "Successfully processed" });
}
No idea what’s going wrong here. Shouldn’t the get function pass the model to the post one, and the review.Id not get lost?
2
Answers
SellerId actually is in get method when you call get method and u see your view seller id is null bcos your not post it you need seller id in your post method just it !
Try the below code it will hit your post method