public ActionResult CreateComment(Comment comment) { if (ModelState.IsValid) { //Select the gamer based on logged in usr name comment.GamerId = db.Gamers.First(x => User.Identity.Name == x.Name).GamerId; db.Comments.Add(comment); db.SaveChanges(); } return RedirectToAction("Details", new { id = comment.GameReviewId }); }
//overload for more detail private ActionResult RedirectToCommentOrigin(string orgin, Comment comment) { return RedirectToAction("Details", orgin, new {id = orgin == "GameReviews" ? comment.GameReviewId : comment.GamerId}); }