public async Task <CommentReply> AddReply(Guid commentId, string replyContent) { var cmt = await _commentRepo.GetAsync(commentId); if (cmt is null) { throw new InvalidOperationException($"Comment {commentId} is not found."); } var id = Guid.NewGuid(); var model = new CommentReplyEntity { Id = id, ReplyContent = replyContent, ReplyTimeUtc = DateTime.UtcNow, CommentId = commentId }; await _commentReplyRepo.AddAsync(model); var reply = new CommentReply { CommentContent = cmt.CommentContent, CommentId = commentId, Email = cmt.Email, Id = model.Id, PostId = cmt.PostId, PubDateUtc = cmt.Post.PubDateUtc.GetValueOrDefault(), ReplyContent = model.ReplyContent, ReplyContentHtml = ContentProcessor.MarkdownToContent(model.ReplyContent, ContentProcessor.MarkdownConvertType.Html), ReplyTimeUtc = model.ReplyTimeUtc, Slug = cmt.Post.Slug, Title = cmt.Post.Title }; await _audit.AddAuditEntry(EventType.Content, AuditEventId.CommentReplied, $"Replied comment id '{commentId}'"); return(reply); }
private string FormatPostContent(string rawContent) { return(_settings.Editor == EditorChoice.Markdown ? ContentProcessor.MarkdownToContent(rawContent, ContentProcessor.MarkdownConvertType.Html, false) : rawContent); }