public static List<CommentsModel> AddComment(CommentsModel entity) { var commentId = CommentsList.Max(a => a.CommentId) + 1; CommentsList.Add(new CommentsModel { CommentId = commentId, Comment = entity.Comment, ProductId = entity.ProductId, Username = Environment.MachineName, CommentedDate = DateTime.Now }); SessionHelper.SetSession("Comments", CommentsList); return (SessionHelper.GetSession("Comments") as List<CommentsModel>).Where(a => a.ProductId == entity.ProductId).ToList(); }
public ActionResult PostComment(int productId, string commentText) { var entity = new CommentsModel { Comment = commentText, ProductId = productId }; var commentslst = CommentsHelper.AddComment(entity); return PartialView("Comments", commentslst); }