public Document GetCommentToArticle(string id) { ///////////////////////////////////////////////////// // Get Comment to related Article by Comment identifier from repository ///////////////////////////////////////////////////// var commentToArticle = BloggingRepository.GetCommentToArticle(Convert.ToInt64(id)); ///////////////////////////////////////////////////// // Build JSON API document ///////////////////////////////////////////////////// var currentRequestUri = this.Request.GetUri(); using (var documentContext = new BloggingDocumentContext(currentRequestUri)) { var document = documentContext .NewDocument(currentRequestUri) .SetJsonApiVersion(JsonApiVersion.Version10) .Links() .AddUpLink() .AddSelfLink() .LinksEnd() .Resource(commentToArticle) .Relationships() .AddRelationship("blog", new[] { Keywords.Related }) .AddRelationship("author", new[] { Keywords.Related }) .AddRelationship("comments", new[] { Keywords.Related }) .RelationshipsEnd() .Links() .AddSelfLink() .LinksEnd() .ResourceEnd() .WriteDocument(); return(document); } }