Beispiel #1
0
        public IWordConverter GetConverterByMethod(WordConvertingMethod method)
        {
            IWordConverter converter = null;

            if (_converters.Any(d => d.MethodName == method))
            {
                converter = _converters.First(d => d.MethodName == method);
            }
            else
            {
                throw new Exception("Cannot find format converter!");
            }
            return(converter);
        }
Beispiel #2
0
        public async Task <IActionResult> PostConvert([FromBody] WordProcessingRequest request)
        {
            var processResult = await _wordProcessingService.ProcessSentenceAsync(request.SentenceStrings);

            if (processResult != null)
            {
                WordConvertingMethod method = ParseStringToEnum(request.ConvertMethod);
                string convertResult        = await _wordProcessingService.ConvertSentencesAsync(processResult, method);

                if (!string.IsNullOrEmpty(convertResult))
                {
                    return(Ok(convertResult));
                }
            }
            return(BadRequest());
        }
Beispiel #3
0
        public async Task <string> ConvertSentencesAsync(SentenceProcessResult sentences, WordConvertingMethod method)
        {
            IWordConverter converter = _converterProvider.GetConverterByMethod(method);

            return(await converter.ConvertSentencesAsync(sentences));
        }