public StreamComment UpdateComment(String text, StreamComment comment) { try { CommentApi commentApi = new CommentApi(session.GetApiClient()); CommentV2Record commentRecord = comment.Record; commentRecord.Text = text; UpdateCommentInput updateCommentInput = new UpdateCommentInput(comment.ContentKey, commentRecord); UpdateCommentResult updateCommentResult = commentApi.UpdateComment(updateCommentInput); if (updateCommentResult.Hdr.Rc == 0) { CommentV2Record updatedCommentRecord = updateCommentResult.Comment; StreamComment updatedComment = new StreamComment(updatedCommentRecord, comment.ContentRecordType); return(updatedComment); } else { throw new Exception("Error creating comment. Rc=" + updateCommentResult.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Error creating comment", ex); } }
public List <StreamComment> GetComments(StreamItem streamItem, PaginationRecord pg) { CommentApi commentApi = new CommentApi(session.GetApiClient()); try { CommentListV2OptionsRecord options = new CommentListV2OptionsRecord(); options.SortDir = "DESC"; options.HighlightTag = "mark"; options.CreatorFilter = "all"; options.ReadFilter = "all"; options.SortFilter = "updateTime"; AdditionalDataRecord additionalData = new AdditionalDataRecord(); additionalData.SubType = "general"; additionalData.FirstLevelCount = true; GetCommentsResult getCommentsResult = commentApi.GetComments(streamItem.Key, options.ToJson(), pg.ToJson(), streamItem.CommentListKey, additionalData.ToJson()); if (getCommentsResult.Hdr.Rc == 0) { commentsPager = getCommentsResult.Pager; List <StreamComment> comments = new List <StreamComment>(); List <CommentV2Record> commentRecords = getCommentsResult.Comments; foreach (CommentV2Record commentRecord in commentRecords) { StreamComment comment = new StreamComment(commentRecord, streamItem.RecordType); comments.Add(comment); } return(comments); } else { throw new Exception("Error getting comments for contentKey " + streamItem.Key); } } catch (Exception ex) { throw new Exception("Error getting comments for contentKey " + streamItem.Key, ex); } }
private StreamComment CreateComment(String text, String contentKey, String contentRecordType, String commentListKey, int principalCommentId) { try { CommentApi commentApi = new CommentApi(session.GetApiClient()); CommentV2Record commentRecord = new CommentV2Record(); commentRecord.ContentKey = contentKey; if (principalCommentId > 0) { commentRecord.CommentPID = principalCommentId; } if (commentListKey != null) { commentRecord.CommentListKey = commentListKey; } commentRecord.Text = text; CreateCommentInput createCommentInput = new CreateCommentInput(contentKey, commentRecord); CreateCommentResult createCommentResult = commentApi.CreateComment(createCommentInput); if (createCommentResult.Hdr.Rc == 0) { CommentV2Record createdComment = createCommentResult.Comment; StreamComment comment = new StreamComment(createdComment, contentRecordType); return(comment); } else { throw new Exception("Error creating comment. Rc=" + createCommentResult.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Error creating comment", ex); } }
public StreamComment ReplyComment(String text, StreamComment parentComment) { return(CreateComment(text, parentComment.ContentKey, parentComment.ContentRecordType, parentComment.CommentListKey, parentComment.CommentPId)); }