public async Task <IList <BaseDocumentDto> > GetDocumentsAsync(string projectId, string branchName) { await _commonValidator.ProjectHaveToExists(projectId); await _commonValidator.BranchHaveToExists(projectId, branchName); var baseDocuments = new List <BaseDocumentDto>(); var files = await _fileSystemService.GetFilesAsync(projectId, branchName); foreach (var file in files) { var extension = Path.GetExtension(file); var mimeType = MimeTypeMap.GetMimeType(extension); var baseDocument = new BaseDocumentDto { Uri = file, Name = Path.GetFileName(file), ConentType = mimeType }; baseDocuments.Add(baseDocument); } return(baseDocuments); }
public async Task <BranchDto> GetBranchAsync(string projectId, string branchName) { await _commonValidator.ProjectHaveToExists(projectId); await _commonValidator.BranchHaveToExists(projectId, branchName); try { string mkDocsYaml = await _fileSystemService.ReadTextAsync(projectId, branchName, "mkdocs.yml"); var branch = new BranchDto { Name = branchName, MkDocsYaml = mkDocsYaml }; return(branch); } catch (MkDocsFileNotFoundException) { _logger.LogWarning($"Branch '{branchName}' in project '{projectId}' doesn't have mkdocs file."); throw new MkDocsFileNotFoundException($"MkDocs configuration file for branch '{branchName}' in project '{projectId}' not found."); } }