public async Task <YandexAnswer> GetDictionaryAnswerAsync(string text, TranslationDirection direction)
        {
            var answer = new YandexAnswer
            {
                Lang             = GetLang(direction),
                DictionaryAnswer = new Dictionary()
            };

            if (String.IsNullOrWhiteSpace(text))
            {
                answer.Text = "Нет слова(ов) для перевода";
                return(answer);
            }

            var address = String.Concat(_addressDictionary,
                                        "&lang=", answer.Lang, "&text=", text);

            answer = await GetAnswerAsync(address, answer);

            return(answer);
        }
        public async Task <YandexAnswer> GetTranslateAnswerAsync(string text, TranslationDirection direction)
        {
            var answer = new YandexAnswer
            {
                Lang             = GetLang(direction),
                TranslatorAnswer = new Translator()
            };

            if (String.IsNullOrWhiteSpace(text))
            {
                answer.Text = "Нет текста для перевода";
                return(answer);
            }

            var address = String.Concat(_addressTranslator,
                                        "&lang=", answer.Lang, "&text=", text);

            answer = await GetAnswerAsync(address, answer);

            return(answer);
        }
        private async Task <YandexAnswer> GetAnswerAsync(string address, YandexAnswer answer)
        {
            var response = await _httpClient.GetAsync(address);

            if (response.IsSuccessStatusCode)
            {
                var json = await response.Content.ReadAsStringAsync();

                if (answer.DictionaryAnswer != null)
                {
                    answer.DictionaryAnswer = JsonConvert.DeserializeObject <Dictionary>(json);
                }
                else
                {
                    answer.TranslatorAnswer = JsonConvert.DeserializeObject <Translator>(json);
                }
            }
            else
            {
                answer.Text = "Ошибка доступа к сервису Яндекса";
            }
            answer.Code = response.StatusCode.ToString();
            return(answer);
        }