private async void OnItemSelected(object sender, SelectedItemChangedEventArgs e) { RateInfoTable selectedFriend = (RateInfoTable)e.SelectedItem; PageRequestHistoryDescription friendPage = new PageRequestHistoryDescription(); friendPage.BindingContext = selectedFriend; await Navigation.PushAsync(friendPage); }
public int SaveItem(RateInfoTable item) { if (item.Id != 0) { database.Update(item); return(item.Id); } else { return(database.Insert(item)); } }
public async void getValute(string name) { string url = "https://www.cbr-xml-daily.ru/daily_json.js"; try { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(url); var response = await client.GetAsync(client.BaseAddress); response.EnsureSuccessStatusCode(); var content = await response.Content.ReadAsStringAsync(); JObject o = JObject.Parse(content); var str = o.SelectToken(@"$.Valute." + name); var rateInfo = JsonConvert.DeserializeObject <RateInfo>(str.ToString()); this.Value = rateInfo.Value; this.Previous = rateInfo.Previous; this.CharCode = rateInfo.CharCode; this.Name = rateInfo.Name; this.Nominal = rateInfo.Nominal; str = o.SelectToken(@"$"); rateInfo = JsonConvert.DeserializeObject <RateInfo>(str.ToString()); this.Date = rateInfo.Timestamp; RateInfoTable objectRateInfo = new RateInfoTable(); objectRateInfo.Timestamp = DateTime.Now.ToString(); objectRateInfo.CharCode = this.charcode; objectRateInfo.Name = this.name; objectRateInfo.Nominal = this.nominal; objectRateInfo.Value = this.value; objectRateInfo.Previous = this.previous; App.Database.SaveItem(objectRateInfo); } catch (Exception ex) { } }