示例#1
0
        protected async Task NotifyAboutNewCommentAsync(Comment comment)
        {
            var courseId = comment.CourseId;

            if (!comment.IsTopLevel)
            {
                var parentComment = await commentsRepo.FindCommentByIdAsync(comment.ParentCommentId).ConfigureAwait(false);

                if (parentComment != null)
                {
                    var replyNotification = new RepliedToYourCommentNotification
                    {
                        Comment       = comment,
                        ParentComment = parentComment,
                    };
                    await notificationsRepo.AddNotificationAsync(courseId, replyNotification, comment.AuthorId).ConfigureAwait(false);
                }
            }

            /* Create NewComment[ForInstructors]Notification later than RepliedToYourCommentNotification, because the last one is blocker for the first one.
             * We don't send NewComment[ForInstructors]Notification if RepliedToYouCommentNotification exists */
            var notification = comment.IsForInstructorsOnly
                                ? (Notification) new NewCommentForInstructorsOnlyNotification {
                Comment = comment
            }
                                : new NewCommentNotification {
                Comment = comment
            };
            await notificationsRepo.AddNotificationAsync(courseId, notification, comment.AuthorId).ConfigureAwait(false);
        }
示例#2
0
        public async Task AddAndFindComment()
        {
            var userId = Guid.NewGuid().ToString();

            var comment = await commentsRepo.AddCommentAsync(userId, "courseId", Guid.NewGuid(), -1, false, "Comment text").ConfigureAwait(false);

            var foundComment = await commentsRepo.FindCommentByIdAsync(comment.Id).ConfigureAwait(false);

            Assert.AreEqual(comment, foundComment);
        }