public async Task <IEnumerable <ExchangeRate> > GetExchangeRates(DateTime date) { using (var client = new ExchangeRatesSoapClient(ExchangeRatesSoapClient.EndpointConfiguration.ExchangeRatesSoap, webServiceUrl)) { var soapResult = await client.getExchangeRatesByDateAsync(new LbExchangeRates.getExchangeRatesByDateRequest(date.Date.ToString("yyyy-MM-dd HH:mm:ss"))); var exchangeRateElements = soapResult.getExchangeRatesByDateResult.Elements(); var exchangeRates = exchangeRateElements.Select(v => new ExchangeRate() { Date = Convert.ToDateTime(v.Element("date").Value), Currency = v.Element("currency").Value, Quantity = Convert.ToInt32(v.Element("quantity").Value), Rate = Convert.ToDecimal(v.Element("rate").Value), Unit = v.Element("unit").Value }); return(exchangeRates); } }
private async Task <List <CurrencyItem> > GetFromSoap(string date) { var client = new ExchangeRatesSoapClient(EndpointConfiguration.ExchangeRatesSoap); var response = await client.getExchangeRatesByDateAsync(date); var resultList = new List <CurrencyItem>(); foreach (XmlNode item in response.ChildNodes) { var tempCurrencyItem = new CurrencyItem() { Currency = item["currency"].InnerText, Quantity = Convert.ToInt32(item["quantity"].InnerText), Rate = double.Parse(item["rate"].InnerText, System.Globalization.CultureInfo.InvariantCulture) }; resultList.Add(tempCurrencyItem); } ; return(resultList); }