private async Task NotifyAboutNewComment(Comment comment) { var courseId = comment.CourseId; if (!comment.IsTopLevel()) { var parentComment = commentsRepo.FindCommentById(comment.ParentCommentId); if (parentComment != null) { var replyNotification = new RepliedToYourCommentNotification { Comment = comment, ParentComment = parentComment, }; await notificationsRepo.AddNotification(courseId, replyNotification, comment.AuthorId); } } /* Create NewCommentNotification later than RepliedToYourCommentNotification, because the last one is blocker for the first one. * We don't send NewCommentNotification if there is a RepliedToYouCommentNotification */ var notification = comment.IsForInstructorsOnly ? (Notification) new NewCommentForInstructorsOnlyNotification { Comment = comment } : new NewCommentNotification { Comment = comment }; await notificationsRepo.AddNotification(courseId, notification, comment.AuthorId); }
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); }