Ejemplo n.º 1
0
        public static NestedComment Map(this usp_CommentTree_Result treeComment, IPrincipal user, string submissionOwnerName, IEnumerable <VotedValue> commentVotes = null, IEnumerable <BlockedItem> userBlocks = null)
        {
            NestedComment result = null;

            if (treeComment != null)
            {
                result                     = new NestedComment();
                result.ID                  = treeComment.ID;
                result.ParentID            = treeComment.ParentID;
                result.ChildCount          = treeComment.ChildCount.Value;
                result.Children.TotalCount = result.ChildCount;
                result.Content             = treeComment.Content;
                result.FormattedContent    = treeComment.FormattedContent;
                result.UserName            = treeComment.UserName;
                result.UpCount             = (int)treeComment.UpCount;
                result.DownCount           = (int)treeComment.DownCount;
                result.CreationDate        = treeComment.CreationDate;
                result.IsAnonymized        = treeComment.IsAnonymized;
                result.IsDeleted           = treeComment.IsDeleted;
                result.IsDistinguished     = treeComment.IsDistinguished;
                result.LastEditDate        = treeComment.LastEditDate;
                result.SubmissionID        = treeComment.SubmissionID;
                result.Subverse            = treeComment.Subverse;
                result.IsSubmitter         = (treeComment.UserName == submissionOwnerName);

                //Set User State and secure comment
                HydrateUserData(user, result, false, commentVotes, userBlocks);
            }
            return(result);
        }
Ejemplo n.º 2
0
        //HACK: This doesn't belong here.
        public static usp_CommentTree_Result Map(Comment comment)
        {
            var singleComment = new usp_CommentTree_Result()
            {
                Id               = comment.Id,
                CommentContent   = comment.CommentContent,
                Anonymized       = comment.Anonymized,
                ChildCount       = 0,
                Date             = comment.Date,
                Dislikes         = comment.Dislikes,
                Depth            = 0,
                FormattedContent = comment.FormattedContent,
                IsDistinguished  = comment.IsDistinguished,
                LastEditDate     = comment.LastEditDate,
                Likes            = comment.Likes,
                MessageId        = comment.MessageId,
                Name             = comment.Name,
                ParentId         = comment.ParentId,
                Path             = "",
                Subverse         = "",
                Votes            = comment.Votes
            };

            return(singleComment);
        }
Ejemplo n.º 3
0
        public static usp_CommentTree_Result MapToTree(this Domain.Models.Comment comment)
        {
            usp_CommentTree_Result result = null;

            if (comment != null)
            {
                result = new usp_CommentTree_Result()
                {
                    ChildCount       = 0,
                    Depth            = 0,
                    Path             = "",
                    Subverse         = comment.Subverse,
                    ID               = comment.ID,
                    ParentID         = comment.ParentID,
                    Content          = comment.Content,
                    FormattedContent = comment.FormattedContent,
                    CreationDate     = comment.CreationDate,
                    LastEditDate     = comment.LastEditDate,
                    SubmissionID     = comment.SubmissionID,
                    UpCount          = comment.UpCount,
                    DownCount        = comment.DownCount,
                    IsDistinguished  = comment.IsDistinguished,
                    IsDeleted        = comment.IsDeleted,
                    IsAnonymized     = comment.IsAnonymized,
                    UserName         = comment.UserName
                };
            }
            return(result);
        }
Ejemplo n.º 4
0
            //HACK ATTACK: This is short term hack. Sorry.
            public static void AddCommentToTree(Comment comment)
            {
                var t = new Task(() => {
                    try
                    {
                        string key = CacheHandler.Keys.CommentTree(comment.MessageId.Value);

                        //not in any way thread safe, will be jacked in high concurrency situations
                        var c = CommentBucketViewModel.Map(comment);

                        CacheHandler.Replace <List <usp_CommentTree_Result> >(key, new Func <List <usp_CommentTree_Result>, List <usp_CommentTree_Result> >(currentData =>
                        {
                            usp_CommentTree_Result parent = null;
                            if (c.ParentId != null)
                            {
                                parent             = currentData.FirstOrDefault(x => x.Id == c.ParentId);
                                parent.ChildCount += 1;
                            }
                            currentData.Add(c);

                            return(currentData);
                        }));
                    }
                    catch (Exception ex)
                    {
                        /*no-op*/
                    }
                });

                t.Start();
            }
Ejemplo n.º 5
0
        //HACK: This doesn't belong here.
        public static usp_CommentTree_Result Map(Comment comment)
        {
            var singleComment = new usp_CommentTree_Result()
            {
                ID               = comment.ID,
                Content          = comment.Content,
                IsAnonymized     = comment.IsAnonymized,
                ChildCount       = 0,
                CreationDate     = comment.CreationDate,
                DownCount        = comment.DownCount,
                Depth            = 0,
                FormattedContent = comment.FormattedContent,
                IsDistinguished  = comment.IsDistinguished,
                LastEditDate     = comment.LastEditDate,
                UpCount          = comment.UpCount,
                SubmissionID     = comment.SubmissionID,
                UserName         = comment.UserName,
                ParentID         = comment.ParentID,
                Path             = "",
                Subverse         = "",
                Votes            = comment.Votes
            };

            return(singleComment);
        }
Ejemplo n.º 6
0
 //HACK: This doesn't belong here.
 public static usp_CommentTree_Result Map(Comment comment) {
     var singleComment = new usp_CommentTree_Result()
     {
         ID = comment.ID,
         Content = comment.Content,
         IsAnonymized = comment.IsAnonymized,
         ChildCount = 0,
         CreationDate = comment.CreationDate,
         DownCount = comment.DownCount,
         Depth = 0,
         FormattedContent = comment.FormattedContent,
         IsDistinguished = comment.IsDistinguished,
         LastEditDate = comment.LastEditDate,
         UpCount = comment.UpCount,
         SubmissionID = comment.SubmissionID,
         UserName = comment.UserName,
         ParentID = comment.ParentID,
         Path = "",
         Subverse = "",
         Votes = comment.Votes
     };
     return singleComment;
 }
Ejemplo n.º 7
0
 //HACK: This doesn't belong here.
 public static usp_CommentTree_Result Map(Comment comment)
 {
     var singleComment = new usp_CommentTree_Result()
     {
         Id = comment.Id,
         CommentContent = comment.CommentContent,
         Anonymized = comment.Anonymized,
         ChildCount = 0,
         Date = comment.Date,
         Dislikes = comment.Dislikes,
         Depth = 0,
         FormattedContent = comment.FormattedContent,
         IsDistinguished = comment.IsDistinguished,
         LastEditDate = comment.LastEditDate,
         Likes = comment.Likes,
         MessageId = comment.MessageId,
         Name = comment.Name,
         ParentId = comment.ParentId,
         Path = "",
         Subverse = "",
         Votes = comment.Votes
     };
     return singleComment;
 }