Пример #1
0
        public ActionResult GetComments(string commentId = null)
        {
            Comment comment;
            var     userId = User.Identity.GetUserId();

            if (string.IsNullOrEmpty(commentId))
            {
                comment = new Comment {
                    MapId = null, Comments = new List <CommentModel>()
                };
                _commentManager.AddComment(comment);
                commentId = comment.Id;
            }
            var commentsList = _commentManager.GetCommentById(commentId).Comments;

            commentsList.ForEach(x => x.CreatedByCurrentUser = (x.CreatorId == userId));

            commentsList.ForEach(x => {
                x.CreatedByCurrentUser = (x.CreatorId == userId);
                x.UserHasUpvoted       = (x.Voters.Contains(userId));
            });

            var jCommentsList = ConvertToJsonCommentModelList(commentsList);

            return(Json(new { cId = commentId, cList = jCommentsList }));
        }