public List <CoinsModel> GetAllQuotationValue(List <CoinsModel> coinList) { try { List <CoinsModel> dadosCotacao = new List <CoinsModel>(); using (StreamReader sr = new StreamReader(pathDadosCotacao)) { string headerLine = sr.ReadLine(); string line; while ((line = sr.ReadLine()) != null) { CoinsModel coin = new CoinsModel(); var arrayLine = line.Split(';'); coin.ValorCotacao = Convert.ToDouble(arrayLine.ElementAt(0)); coin.CodigoCotacao = Convert.ToInt32(arrayLine.ElementAt(1)); coin.DataCotacao = Convert.ToDateTime(arrayLine.ElementAt(2)).ToString("yyyy-MM-dd"); dadosCotacao.Add(coin); } foreach (var coin in coinList) { coin.ValorCotacao = (from d in dadosCotacao where (d.CodigoCotacao == coin.CodigoCotacao) && (d.DataCotacao == coin.DataCotacao) select d.ValorCotacao).First(); } } return(coinList); } catch (Exception e) { Console.WriteLine(e.Message); throw new ArgumentException(e.Message); } }
public List <CoinsModel> GetQuotationCode(List <CoinsModel> coinList) { try { List <CoinsModel> dePara = new List <CoinsModel>(); using (StreamReader sr = new StreamReader(pathDePara)) { string headerLine = sr.ReadLine(); string line; while ((line = sr.ReadLine()) != null) { CoinsModel coin = new CoinsModel(); var arrayLine = line.Split(';'); coin.Moeda = arrayLine.ElementAt(0); coin.CodigoCotacao = Convert.ToInt32(arrayLine.ElementAt(1)); dePara.Add(coin); } foreach (var coin in coinList) { coin.CodigoCotacao = (from d in dePara where (d.Moeda == coin.Moeda) select d.CodigoCotacao).First(); } } return(coinList); } catch (Exception e) { Console.WriteLine(e.Message); throw new ArgumentException(e.Message); } }
static public async Task <CoinsModel> GetCoin() { try { HttpResponseMessage response = await httpClient.GetAsync("api/Coins"); if (response.IsSuccessStatusCode) { coin = await response.Content.ReadAsAsync <CoinsModel>(); } else { coin = null; } return(coin); } catch (Exception e) { Console.WriteLine(e.Message); throw new ArgumentException(e.Message); } }
public List <CoinsModel> GetListCoins(CoinsModel apiCoin) { try { List <CoinsModel> dadosMoeda = new List <CoinsModel>(); List <CoinsModel> coinList = new List <CoinsModel>(); using (StreamReader sr = new StreamReader(pathDadosMoeda)) { string headerLine = sr.ReadLine(); string line; while ((line = sr.ReadLine()) != null) { CoinsModel coin = new CoinsModel(); var arrayLine = line.Split(';'); coin.Moeda = arrayLine.ElementAt(0); coin.DataCotacao = arrayLine.ElementAt(1); dadosMoeda.Add(coin); } foreach (var coin in dadosMoeda) { if (dateChecker(apiCoin.DataInicio, apiCoin.DataFim, coin.DataCotacao)) { coinList.Add(coin); } } } return(coinList); } catch (Exception e) { Console.WriteLine(e.Message); throw new ArgumentException(e.Message); } }