//example http://localhost:5001/api/questions/thread/19 //get the whole thread of question+asnswers public ActionResult GetThread(int questionId, int?postId) { (int userId, bool useridok) = GetAuthUserId(); var checkthatpost = _sharedService.GetPostType(questionId); if (checkthatpost == "answers") { questionId = _sharedService.GetPost(questionId).QuestionId; if (postId != null) { postId = questionId; } } else if (checkthatpost == null) { return(NotFound()); } var t = _sharedService.GetThread(questionId); if (t != null && useridok) // then we got a thread! { ///call to add browse history here History browsehist = new History { Userid = userId }; if (postId != null) { browsehist.Postid = (int)postId; } else { browsehist.Postid = questionId; } _historyService.Add(browsehist); //createthreaddto List <PostsThreadDto> thread = new List <PostsThreadDto>(); foreach (Posts p in t) { PostsThreadDto pt = new PostsThreadDto { Id = p.Id, Parentid = p.Parentid, Title = p.Title, Body = p.Body }; PagingAttributes pagingAttributes = new PagingAttributes(); List <SimpleAnnotationDto> tempanno = new List <SimpleAnnotationDto>(); tempanno = _annotationService.GetUserAnnotationsMadeOnAPost(userId, p.Id, pagingAttributes); pt.Annotations = tempanno; pt.createBookmarkLink = Url.Link(nameof(BookmarkController.AddBookmark), new { postId = p.Id }); AnnotationsDto anno = new AnnotationsDto { Body = "form_or_similar_would_be_here_to_POST_a_new_annotation", PostId = p.Id }; pt.createAnnotationLink = Url.Link(nameof(AnnotationsController.AddAnnotation), anno); // i know its supposed to be a form/post. just thought it'd be neat to have a link mockup. thread.Add(pt); } return(Ok(thread)); } else { return(NotFound()); } }