private async void dropdownFequency_SelectedIndexChanged(object sender, EventArgs e) { var picker = (Picker)sender; int selectedIndex = picker.SelectedIndex; if (selectedIndex != -1) { var data = picker.Items[picker.SelectedIndex]; var WorkoutTypedata = picker.SelectedItem as ListofFrequency; SetReminderType = WorkoutTypedata.Id; Settings.FrequencyName = WorkoutTypedata.Frequency; Settings.FrequencyId = SetReminderType; freq = WorkoutTypedata.Frequency; await Navigation.PushPopupAsync(new LoadingPopPage()); if ((Settings.SetReminderName != "null") && (Settings.BillingReminderName != "null") && (Settings.FrequencyName != "null")) { if (Settings.BillingReminderName != "null") { if (Settings.FrequencyName != "null") { try { priceListReqModel _request = new priceListReqModel(); PriceModelResponse _response; _request.SendVia = Settings.SetReminderName; _request.Billing = Settings.BillingReminderName; _request.Duration = Settings.FrequencyName; string s = JsonConvert.SerializeObject(_request); HttpResponseMessage response = null; string uri = "http://noti.fit:130/api/Price/GetPrice"; using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json")) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Settings.TokenCode); response = await client.PostAsync(uri, stringContent); if (response.IsSuccessStatusCode) { var SucessResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <PriceModelResponse>(SucessResponse); //Settings.PriceName = _response.Response.price; var res = _response.Price; Settings.PriceName = res; await Navigation.PopAllPopupAsync(); Cost.Text = "Total New Subscriptions: US $" + res; //return _response; } else { var ErrorResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <PriceModelResponse>(ErrorResponse); DependencyService.Get <IToast>().Show("Error Occured"); //return _response; //Settings.PriceName = _response.Response.price; } } } catch (Exception ex) { //await Navigation.PopAsync(true); await Navigation.PopAllPopupAsync(); } } else { await DisplayAlert("Alert", "Please select frequency", "Ok"); } } else { await DisplayAlert("Alert", "Please select subscription type", "Ok"); } //priceListReqModel _request = new priceListReqModel(); //PriceModelResponse _response; //_request.SendVia = Settings.SetReminderName; //_request.Billing = Settings.BillingReminderName; //_request.Duration = Settings.FrequencyName; //string s = JsonConvert.SerializeObject(_request); //HttpResponseMessage response = null; //string uri = "http://180.151.232.92:130/api/Price/GetPrice"; //using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json")) //{ // HttpClient client = new HttpClient(); // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Settings.TokenCode); // response = await client.PostAsync(uri, stringContent); // if (response.IsSuccessStatusCode) // { // var SucessResponse = await response.Content.ReadAsStringAsync(); // _response = JsonConvert.DeserializeObject<PriceModelResponse>(SucessResponse); // //Settings.PriceName = _response.Response.price; // var res = _response.Price; // Settings.PriceName = res; // await Navigation.PopAllPopupAsync(); // Cost.Text = "Total New Subscriptions: US $" + res; // //return _response; // } // else // { // var ErrorResponse = await response.Content.ReadAsStringAsync(); // _response = JsonConvert.DeserializeObject<PriceModelResponse>(ErrorResponse); // DependencyService.Get<IToast>().Show("Error Occured"); // //return _response; // //Settings.PriceName = _response.Response.price; // } //} } else { await DisplayAlert("Alert", "Please select send via", "Ok"); } } else { DependencyService.Get <IToast>().Show("please select Type!"); } }
private async void dropdownDuration_SelectedIndexChanged(object sender, EventArgs e) { await Navigation.PushPopupAsync(new LoadingPopPage()); var picker = (Picker)sender; int selectedIndex = picker.SelectedIndex; if (selectedIndex != -1) { try{ var data = picker.Items[picker.SelectedIndex]; var WorkoutTypedata = picker.SelectedItem as ListofFrequency; SetReminderType = WorkoutTypedata.Id; Settings.DurationName = WorkoutTypedata.Frequency; Settings.DurationId = SetReminderType; expirydate = XFDPstartDate.Date.AddMonths(Settings.DurationId); XFDPEndDate.Date = expirydate; priceListReqModel _request = new priceListReqModel(); PriceModelResponse _response; _request.SendVia = Settings.DeliveryMethodName; _request.Billing = Settings.SubscriptionTypeName; _request.Duration = Settings.DurationName; string s = JsonConvert.SerializeObject(_request); HttpResponseMessage response = null; string uri = "http://noti.fit:130/api/Price/GetPrice"; using (var stringContent = new StringContent(s, System.Text.Encoding.UTF8, "application/json")) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Settings.TokenCode); response = await client.PostAsync(uri, stringContent); if (response.IsSuccessStatusCode) { var SucessResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <PriceModelResponse>(SucessResponse); //Settings.PriceName = _response.Response.price; var res = _response.Price; Settings.PriceName = res; CostofPlan.Text = "Total New Subscriptions: US $" + res; await Navigation.PopAllPopupAsync(); //return _response; } else { var ErrorResponse = await response.Content.ReadAsStringAsync(); _response = JsonConvert.DeserializeObject <PriceModelResponse>(ErrorResponse); await DisplayAlert("Alert", "Please select the all dropdown", "Ok"); //return _response; //Settings.PriceName = _response.Response.price; } } } catch (Exception ex) { //await Navigation.PopAsync(true); await Navigation.PopAllPopupAsync(); } } else { DependencyService.Get <IToast>().Show("please select Type!"); } }