Ejemplo n.º 1
0
        public virtual PartialViewResult Delete()
        {
            var deleteCommentId = FullContext.Value.EntityId.Value;
            var commentsTarget  = FullContext.GetCommentsTarget();
            var targetEntityId  = commentsTarget.EntityId.Value;

            var comment = _commentsService.Get(deleteCommentId);

            if (!_commentsService.CanDelete(comment, _intranetMemberService.GetCurrentMemberId()))
            {
                return(OverView(comment.ActivityId));
            }

            var command = new RemoveCommentCommand(FullContext, deleteCommentId);

            _commandPublisher.Publish(command);

            switch (commentsTarget.Type.ToInt())
            {
            case int type
                when ContextExtensions.HasFlagScalar(type, ContextType.Activity | ContextType.PagePromotion):
                var activityCommentsInfo = GetActivityComments(targetEntityId);

                return(OverView(activityCommentsInfo));

            default:
                return(OverView(comment.ActivityId));
            }
        }
Ejemplo n.º 2
0
        public async Task <CommentsOverviewModel> Delete(Guid targetId, IntranetEntityTypeEnum targetType, Guid commentId)
        {
            var comment = await _commentsService.GetAsync(commentId);

            if (!_commentsService.CanDelete(comment, await _intranetMemberService.GetCurrentMemberIdAsync()))
            {
                return(await _commentsHelper.OverViewAsync(comment.ActivityId));
            }

            var command = new RemoveCommentCommand(targetId, targetType, commentId);

            _commandPublisher.Publish(command);

            switch (targetType)
            {
            case IntranetEntityTypeEnum type
                when type.Is(IntranetEntityTypeEnum.News, IntranetEntityTypeEnum.Social, IntranetEntityTypeEnum.Events):
                var activityCommentsInfo = GetActivityComments(targetId);

                return(await _commentsHelper.OverViewAsync(activityCommentsInfo.Id, activityCommentsInfo.Comments, activityCommentsInfo.IsReadOnly));

            default:
                return(await _commentsHelper.OverViewAsync(comment.ActivityId));
            }
        }
Ejemplo n.º 3
0
        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);
        }