Пример #1
0
 public ForumThreadViewModel(ForumThread forumThread, int currentUserId)
 {
     RootComments        = forumThread.CommentDiscussion.ToCommentTreeViewModel(currentUserId);
     ProjectId           = forumThread.ProjectId;
     HasMasterAccess     = forumThread.HasMasterAccess(currentUserId);
     Header              = forumThread.Header;
     ProjectName         = forumThread.Project.ProjectName;
     CommentDiscussionId = forumThread.CommentDiscussionId;
     GroupDetails        = new CharacterGroupDetailsViewModel(forumThread.CharacterGroup, currentUserId, GroupNavigationPage.None);
 }
Пример #2
0
        private async Task <ForumEmail> AddCommentWithEmail(string commentText, ForumThread forumThread,
                                                            bool isVisibleToPlayer, Comment parentComment, IEnumerable <User> extraSubscriptions = null)
        {
            var visibleToPlayerUpdated = isVisibleToPlayer && parentComment?.IsVisibleToPlayer != false;

            if (!isVisibleToPlayer)
            {
                forumThread.RequestMasterAccess(CurrentUserId);
            }

            var comment = new Comment
            {
                CommentId    = -1,
                ProjectId    = forumThread.ProjectId,
                AuthorUserId = CurrentUserId,
                CommentText  = new CommentText()
                {
                    Text      = new MarkdownString(commentText),
                    CommentId = -1
                },
                IsCommentByPlayer = !forumThread.HasMasterAccess(CurrentUserId),
                IsVisibleToPlayer = isVisibleToPlayer,
                Parent            = parentComment,
            };

            forumThread.CommentDiscussion.Comments.Add(comment);

            var extraRecipients =
                new[] { parentComment?.Author, parentComment?.Finance?.PaymentType?.User }.
                Union(extraSubscriptions ?? Enumerable.Empty <User>());
            var subscriptions =
                forumThread.GetSubscriptions(extraRecipients, visibleToPlayerUpdated).ToList();

            return(new ForumEmail()
            {
                ForumThread = forumThread,
                ProjectName = forumThread.Project.ProjectName,
                Initiator = await UserRepository.GetById(CurrentUserId),
                Recipients = subscriptions.ToList(),
                Text = new MarkdownString(commentText),
            });
        }