public async Task SelectedProfile(object sender, Xamarin.Forms.ItemTappedEventArgs e) { SetOnline i = (SetOnline)((ListView)sender).SelectedItem; ((ListView)sender).SelectedItem = null; OnlineWorkout item = new OnlineWorkout(); item.Handle = i.Handle; await Navigation.PushAsync(new Views.Profile.IndividualProfilePage(item)); }
public async Task Handle_Clicked(object sender, System.EventArgs e) { string pickerTwo = ""; string pickerListString = ""; string handle = HandleEntry.Text; string handleForSearch = ""; if (Reps.SelectedIndex != -1) { pickerTwo = Reps.Items[Reps.SelectedIndex]; } if (ExercisePicker.SelectedIndex != -1) { pickerListString = ExercisePicker.Items[ExercisePicker.SelectedIndex]; } if (!string.IsNullOrEmpty(handle)) { handleForSearch = handle; } else { handleForSearch = "Empty"; } if (pickerTwo == "") { pickerTwo = "0"; } if (pickerListString == "") { pickerListString = "Empty"; } if (pickerTwo == "0" || pickerListString == "Empty") { } else { SetOnline setOnline = new SetOnline() { Handle = handleForSearch, Reps = Int32.Parse(pickerTwo), //Weight = decimal.Parse(pickerOne), ExerciseName = pickerListString }; string url = "https://myapi20180503015443.azurewebsites.net/api/OnlineSet/GetSets"; HttpClient client = new HttpClient(); var data = JsonConvert.SerializeObject(setOnline); var content = new StringContent(data, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = JsonConvert.DeserializeObject <List <SetOnline> >(response.Content.ReadAsStringAsync().Result); var results = result.OrderByDescending(n => n.Weight); List <SetOnline> ListOfSets = new List <SetOnline>(); int position = 1; foreach (var item in results) { SetOnline s = new SetOnline() { ExerciseName = item.ExerciseName, Weight = item.Weight, Reps = item.Reps, Handle = item.Handle, SetPosition = position }; position++; ListOfSets.Add(s); } ListOfSetOnline = ListOfSets; OnAppearing(); } }