private List <Currency> GetListCurrency(bool connection) { string text = ""; if (connection) { var client = new WebClient { Encoding = Encoding.UTF8 }; text = client.DownloadString("http://api.nbp.pl/api/exchangerates/tables/a/?format=json"); } else { text = ReadAndWriteJson.ReadJson(); } text = text.TrimStart(new char[] { '[' }).TrimEnd(new char[] { ']' }); JObject serch = JObject.Parse(text); IList <JToken> results = serch["rates"].Children().ToList(); List <Currency> searchResults = new List <Currency>(); foreach (var result in results) { Currency searchResult = result.ToObject <Currency>(); searchResults.Add(searchResult); } return(searchResults); }
private string GetDate() { var text = ReadAndWriteJson.ReadJson(); text = text.TrimStart(new char[] { '[' }).TrimEnd(new char[] { ']' }); JObject serch = JObject.Parse(text); return(Helpers.ReversDate(serch["effectiveDate"].ToString())); }