Exemple #1
0
        private Comment DoGetComment(CommentID commentId)
        {
            var qry = Queries.FindCommentByGDID <CommentRow>(commentId.G_Comment);
            var row = ForComment(commentId.G_Volume).LoadRow(qry);

            if (row == null)
            {
                throw new GraphException("Comment not found, CommendID = {0}".Args(commentId));
            }
            return(GraphCommentFetchStrategy.RowToComment(row));
        }
Exemple #2
0
        /// <summary>
        /// Make response to target commentary
        /// </summary>
        /// <param name="gAuthorNode">Author</param>
        /// <param name="parentId">Parent commentary</param>
        /// <param name="content">Content of commentary</param>
        /// <param name="data">Byte Array</param>
        /// <returns>New CommentID</returns>
        public Comment Respond(GDID gAuthorNode, CommentID parentId, string content, byte[] data)
        {
            try
            {
                if (parentId.IsZero)
                {
                    throw new GraphException(StringConsts.GS_RESPONSE_BAD_PARENT_ID_ERROR);
                }

                var currentDateTime = App.TimeSource.UTCNow;

                // Get parent comment
                var parent = getCommentRow(parentId);

                if (parent == null)
                {
                    throw new GraphException(StringConsts.GS_COMMENT_NOT_FOUND.Args(parentId.G_Comment));
                }
                if (!parent.IsRoot)
                {
                    throw new GraphException(StringConsts.GS_PARENT_ID_NOT_ROOT.Args(parentId.G_Comment));
                }

                var authorNode    = GetNode(gAuthorNode);
                var parentComment = GraphCommentFetchStrategy.RowToComment(parent);

                if (!GraphHost.CanCreateCommentResponse(parentComment, authorNode, currentDateTime))
                {
                    throw new GraphException(StringConsts.GS_CAN_NOT_CREATE_RESPONSE_ERROR.Args(authorNode, parentComment.TargetNode));
                }

                // Create new comment
                return(DoCreate(parentComment.TargetNode,
                                authorNode,
                                parentId,
                                parent.Dimension,
                                content,
                                data,
                                GSPublicationState.ToPublicationState(parent.PublicationState),
                                RatingValue.Undefined,
                                App.TimeSource.UTCNow));
            }
            catch (Exception ex)
            {
                Log(MessageType.Error, "GraphCommentSystem.Response", ex.ToMessageWithType(), ex);
                throw new GraphException(StringConsts.GS_RESPONSE_COMMENT_ERROR.Args(parentId.G_Comment), ex);
            }
        }
Exemple #3
0
 protected virtual IEnumerable <Comment> DoFetch(CommentQuery query)
 {
     return(GraphCommentFetchStrategy.Fetch(query));
 }