Esempio n. 1
0
        public _Comments_CommentViewModel(Comment comment)
        {
            if (comment != null)
            {
                Id           = comment.Id;
                ContentId    = comment.ContentId;
                ContentUrl   = comment.Content.GetUrl(comment);
                ContentTitle = comment.Content.Title;
                Text         = comment.Text.Split(new[] { "\r\n" }, StringSplitOptions.None);
                IsHidden     = comment.IsHidden;
                Rating       = comment.Rating;
                DateTime     = comment.DateTime;
                UserId       = comment.UserId;
                UserName     = comment.User.FirstName;
                UserSurname  = comment.User.SurName;
                UserAvatar   = ImageService.GetImageUrl <User>(comment.User.Avatar);
                if (comment.User.AddressId.HasValue)
                {
                    UserGeo = comment.User.Address.City.Title;
                }

                ChildComments = new List <_Comments_CommentViewModel>();
                if (comment.ParentCommentId == null)
                {
                    ChildComments = comment.ChildComments
                                    .OrderBy(c => c.DateTime).Select(c => new _Comments_CommentViewModel(c)).OrderBy(x => x.DateTime).ToList();
                }

                VisibleChildComments = ChildComments.Count(x => !x.IsHidden);

                if (comment.ReplyTo != null)
                {
                    ReplyComment = new _Comments_CommentReplyViewModel(comment.ReplyTo);
                }

                IsReplied = comment.Replies.Count > 0;
            }
        }
Esempio n. 2
0
        public _Comments_CommentViewModel(Comment comment)
        {
            if (comment != null)
            {
                Id = comment.Id;
                ContentId = comment.ContentId;
                ContentUrl = comment.Content.GetUrl(comment);
                ContentTitle = comment.Content.Title;
                Text = comment.Text.Split(new[] { "\r\n" }, StringSplitOptions.None);
                IsHidden = comment.IsHidden;
                Rating = comment.Rating;
                DateTime = comment.DateTime;
                UserId = comment.UserId;
                UserName = comment.User.FirstName;
                UserSurname = comment.User.SurName;
                UserAvatar = ImageService.GetImageUrl<User>(comment.User.Avatar);
                if (comment.User.AddressId.HasValue)
                    UserGeo = comment.User.Address.City.Title;

                ChildComments = new List<_Comments_CommentViewModel>();
                if (comment.ParentCommentId == null)
                    ChildComments = comment.ChildComments
                        .OrderBy(c => c.DateTime).Select(c => new _Comments_CommentViewModel(c)).OrderBy(x => x.DateTime).ToList();

                VisibleChildComments = ChildComments.Count(x => !x.IsHidden);

                if (comment.ReplyTo != null)
                    ReplyComment = new _Comments_CommentReplyViewModel(comment.ReplyTo);

                IsReplied = comment.Replies.Count > 0;
            }
        }