示例#1
0
        /// <summary>
        /// Получение информации по
        /// </summary>
        /// <param name="currencyId"></param>
        /// <returns></returns>
        public async Task <Currency> GetCurrency(string currencyId)
        {
            CbDaily currencies = await GetDailyRates();

            Currency currency = currencies.Valute.Values.Where(c => c.Id == currencyId).FirstOrDefault();

            return(currency);
        }
示例#2
0
        /// <summary>
        /// Получение ежедневной иформации по валютам ЦБ
        /// </summary>
        /// <returns></returns>
        public async Task <CbDaily> GetDailyRates()
        {
            HttpClient client = new HttpClient();

            HttpResponseMessage response = await client.GetAsync("https://www.cbr-xml-daily.ru/daily_json.js");

            string currenciesAsString = await response.Content.ReadAsStringAsync();

            CbDaily currencies = JsonConvert.DeserializeObject <CbDaily>(currenciesAsString);

            return(currencies);
        }