private async Task SetDocumentAsync() { DocumentNameWithExtension = DocumentName + "." + Project.Format; try { if (DocumentName.IsNullOrWhiteSpace()) { Document = await _documentAppService.GetDefaultAsync( new GetDefaultDocumentInput { ProjectId = Project.Id, LanguageCode = LanguageCode, Version = Version } ); } else { Document = await _documentAppService.GetAsync( new GetDocumentInput { ProjectId = Project.Id, Name = DocumentNameWithExtension, LanguageCode = LanguageCode, Version = Version } ); } } catch (DocumentNotFoundException) { if (LanguageCode != DefaultLanguageCode) { Document = await _documentAppService.GetAsync( new GetDocumentInput { ProjectId = Project.Id, Name = DocumentNameWithExtension, LanguageCode = DefaultLanguageCode, Version = Version } ); DocumentLanguageIsDifferent = true; } else { throw; } } await ConvertDocumentContentToHtmlAsync(); }
private async Task <List <DocumentPartialTemplateContent> > GetDocumentPartialTemplatesAsync() { var partialTemplatesInDocument = await _documentSectionRenderer.GetPartialTemplatesInDocumentAsync(Document.Content); if (!partialTemplatesInDocument?.Any(t => t.Parameters != null) ?? true) { return(null); } foreach (var partialTemplates in partialTemplatesInDocument) { foreach (var parameter in partialTemplates.Parameters) { if (!UserPreferences.ContainsKey(parameter.Key)) { UserPreferences.Add(parameter.Key, parameter.Value); } else { UserPreferences[parameter.Key] = parameter.Value; } } } var contents = new List <DocumentPartialTemplateContent>(); foreach (var partialTemplate in partialTemplatesInDocument) { var content = (await _documentAppService.GetAsync(new GetDocumentInput { LanguageCode = DocumentLanguageCode, Name = partialTemplate.Path, ProjectId = Project.Id, Version = Version })).Content; contents.Add(new DocumentPartialTemplateContent { Path = partialTemplate.Path, Content = content }); } return(contents); }
private async Task SetDocumentAsync() { if (DocumentName.IsNullOrWhiteSpace()) { DocumentName = Project.DefaultDocumentName; } DocumentNameWithExtension = DocumentName + "." + Project.Format; try { if (DocumentNameWithExtension.IsNullOrWhiteSpace()) { Document = await _documentAppService.GetDefaultAsync( new GetDefaultDocumentInput { ProjectId = Project.Id, Version = Version } ); } else { Document = await _documentAppService.GetAsync( new GetDocumentInput { ProjectId = Project.Id, Name = DocumentNameWithExtension, Version = Version } ); } } catch (DocumentNotFoundException) { //TODO: Handle it! throw; } ConvertDocumentContentToHtml(); }
public async Task <DocumentDto> GetAsync(long id) { return(await _documentAppService.GetAsync(id)); }