protected virtual CommentViewModel GetCommentView(CommentModel comment, Guid currentUserId, IIntranetUser creator) { var model = comment.Map <CommentViewModel>(); model.ModifyDate = _commentsService.WasChanged(comment) ? comment.ModifyDate : default(DateTime?); model.CanEdit = _commentsService.CanEdit(comment, currentUserId); model.CanDelete = _commentsService.CanDelete(comment, currentUserId); model.Creator = creator; model.ElementOverviewId = GetOverviewElementId(comment.ActivityId); model.CommentViewId = _commentsService.GetCommentViewId(comment.Id); model.CreatorProfileUrl = _profileLinkProvider.GetProfileLink(creator); model.LinkPreview = comment.LinkPreview.Map <LinkPreviewViewModel>(); return(model); }
public virtual CommentViewModel GetCommentView(CommentModel comment, Guid currentMemberId, IIntranetMember creator) { var likes = _likesService.GetLikeModels(comment.Id).ToArray(); var memberId = _intranetMemberService.GetCurrentMemberId(); var model = comment.Map <CommentViewModel>(); model.ModifyDate = _commentsService.WasChanged(comment) ? comment.ModifyDate.ToDateTimeFormat() : null; model.CanEdit = _commentsService.CanEdit(comment, currentMemberId); model.CanDelete = _commentsService.CanDelete(comment, currentMemberId); model.Creator = creator.ToViewModel(); model.ElementOverviewId = GetOverviewElementId(comment.ActivityId); model.CommentViewId = _commentsService.GetCommentViewId(comment.Id); model.CreatorProfileUrl = creator == null ? null : _profileLinkProvider.GetProfileLink(creator); model.LinkPreview = comment.LinkPreview.Map <LinkPreviewModel>(); model.LikedByCurrentUser = likes.Any(el => el.UserId == memberId); model.Likes = likes; model.LikeModel = GetLikesViewModel(comment.Id, memberId, likes); return(model); }