Example #1
0
        public async Task ConcealComment(int projectId,
                                         int commentId,
                                         int commentDiscussionId,
                                         int currentUserId)
        {
            var discussion = await ForumRepository.GetDiscussionByComment(projectId, commentId);

            var childComments = discussion.Comments.Where(c => c.ParentCommentId == commentId);
            var comment       = discussion.Comments.FirstOrDefault(coment => coment.CommentId == commentId);

            if (comment == null)
            {
                throw new JoinRpgEntityNotFoundException(commentId, nameof(Comment));
            }

            if (comment.HasMasterAccess(currentUserId) && !childComments.Any() &&
                comment.IsVisibleToPlayer && !comment.IsCommentByPlayer)
            {
                comment.IsVisibleToPlayer = false;
                await UnitOfWork.SaveChangesAsync();
            }
            else
            {
                throw new JoinRpgConcealCommentException();
            }
        }
Example #2
0
        public async Task <ActionResult> RedirectToDiscussion(int projectid,
                                                              int?commentid,
                                                              int?commentDiscussionId)
        {
            CommentDiscussion discussion;

            if (commentid != null)
            {
                discussion = await ForumRepository.GetDiscussionByComment(projectid, (int)commentid);
            }
            else if (commentDiscussionId != null)
            {
                discussion =
                    await ForumRepository.GetDiscussion(projectid, (int)commentDiscussionId);
            }
            else
            {
                return(HttpNotFound());
            }

            if (!discussion.HasAnyAccess(CurrentUserId))
            {
                return(NoAccesToProjectView(discussion.Project));
            }

            return(ReturnToParent(discussion, commentid != null ? $"comment{commentid}" : null));
        }