public async Task <string> GenerateMarkdown(string projectId, string branchName) { var project = await _projectsService.GetProjectAsync(projectId); if (project == null) { throw new ProjectNotFoundException($"Project '{projectId}' not exists."); } var chapters = await _tableOfContentsService.GetTableOfConents(projectId, branchName); var markdownBuilder = new StringBuilder(); AddTitlePage(project, branchName, markdownBuilder); AddPageBreak(markdownBuilder); AddTableOfContents(chapters, markdownBuilder); AddPageBreak(markdownBuilder); var imagesList = new List <ImageUrl>(); await AddDocumentsContent(projectId, branchName, chapters, markdownBuilder, imagesList); var markdown = markdownBuilder.ToString(); markdown = await EmbedImagesToMarkdown(project.Id, branchName, imagesList, markdown); return(markdown); }
public async Task <IActionResult> Get(string projectId, string branchName) { var rootChapterNodes = await _tableOfContentsService.GetTableOfConents(projectId, branchName); if (rootChapterNodes == null) { return(NotFound()); } return(new ObjectResult(rootChapterNodes)); }
public void Resolve(GraphQLQuery graphQLQuery) { graphQLQuery.Field <ResponseListGraphType <ChapterItemType> >( "chapters", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "projectId", Description = "id of the project" }, new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "branchName", Description = "name of the branch" } ), resolve: context => { var projectId = context.GetArgument <string>("projectId"); var branchName = context.GetArgument <string>("branchName"); var chapters = _tableOfContentsService.GetTableOfConents(projectId, branchName).GetAwaiter().GetResult(); return(Response(chapters)); } ); }