Пример #1
0
        public async Task <DocumentParametersDto> GetParametersAsync(GetParametersDocumentInput input)
        {
            var project = await _projectRepository.GetAsync(input.ProjectId);

            input.Version = GetProjectVersionPrefixIfExist(project) + input.Version;

            try
            {
                if (string.IsNullOrWhiteSpace(project.ParametersDocumentName))
                {
                    return(await Task.FromResult <DocumentParametersDto>(null));
                }

                var document = await GetDocumentWithDetailsDtoAsync(
                    project,
                    project.ParametersDocumentName,
                    input.LanguageCode,
                    input.Version
                    );

                if (!DocsJsonSerializerHelper.TryDeserialize <DocumentParametersDto>(document.Content, out var documentParameters))
                {
                    throw new UserFriendlyException(
                              $"Cannot validate document parameters file '{project.ParametersDocumentName}' for the project {project.Name}.");
                }

                return(documentParameters);
            }
            catch (DocumentNotFoundException)
            {
                Logger.LogWarning($"Parameter file ({project.ParametersDocumentName}) not found!");
                return(new DocumentParametersDto());
            }
        }
Пример #2
0
        public async Task <DocumentParametersDto> GetParametersAsync(GetParametersDocumentInput input)
        {
            var project = await _projectRepository.GetAsync(input.ProjectId);

            try
            {
                if (string.IsNullOrWhiteSpace(project.ParametersDocumentName))
                {
                    return(await Task.FromResult <DocumentParametersDto>(null));
                }

                var document = await GetDocumentWithDetailsDtoAsync(
                    project,
                    project.ParametersDocumentName,
                    input.LanguageCode,
                    input.Version
                    );

                return(JsonConvert.DeserializeObject <DocumentParametersDto>(document.Content));
            }
            catch (DocumentNotFoundException)
            {
                Logger.LogWarning($"Parameter file ({project.ParametersDocumentName}) not found.");
                return(new DocumentParametersDto());
            }
        }
Пример #3
0
 public Task <DocumentParametersDto> GetParametersAsync(GetParametersDocumentInput input)
 {
     return(DocumentAppService.GetParametersAsync(input));
 }