private async Task GetListPaymentGetwayAsync() { //paymentGetways = new ObservableCollection<PaymentGetway>(); var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { paymentGetways = await _paymentGetwayService.GetPaymentGetwaysAsync(); if (paymentGetways != null) { foreach (var method in paymentGetways) { PaymentGetway list = new PaymentGetway(); list.id = method.id; list.title = method.title; await _connection.InsertAsync(list); } } } else { await Application.Current.MainPage.DisplayAlert("", "Please Connect with Internet.", "ok"); //Isbusy = false; } }
public SummaryViewModel(INavigation navigation, PaymentGetway _paymentGetway) { this.methods = _paymentGetway; Itemlst = new List <LineItems>(); _BillingDetailService = new GetBillingDetailbyId(); placeOrderApi = new PlaceOrderApi(); getDetailById = new GetDetailById(); _loginService = new LoginService(); order = new OrderDetailModel(); this.navigation = navigation; _connection = Xamarin.Forms.DependencyService.Get <ISQLiteDb>().GetConnection(); _ = getallcaetitem(); }
public async Task <List <PaymentGetway> > GetPaymentGetwaysAsync() { List <PaymentGetway> getresponse = new List <PaymentGetway>(); var Httpclient = new HttpClient(); var url = Constants.BaseApiAddress + "wp-json/wc/v3/payment_gateways" + Constants.Consumer_Key; var uri = new Uri(string.Format(url, string.Empty)); HttpResponseMessage response = null; response = await Httpclient.GetAsync(uri); if (response.StatusCode == HttpStatusCode.OK) { using (var client = new HttpClient()) { var result = await client.GetStringAsync(uri); //dynamic resObj = JsonConvert.DeserializeObject(result.ToString()); List <dynamic> resObj = JsonConvert.DeserializeObject <List <dynamic> >(result); List <PaymentGetway> PaymentMethodList = new List <PaymentGetway>(); if (resObj != null) { foreach (var vrec in resObj) { PaymentGetway sublist = new PaymentGetway(); sublist.id = vrec.id; sublist.title = vrec.title; PaymentMethodList.Add(sublist); } } //var PaymentMethodList = JsonConvert.DeserializeObject<List<PaymentGetway>>(result); getresponse = new List <PaymentGetway>(PaymentMethodList); } //var responseContent = await response.Content.ReadAsStringAsync(); //var jObject = JObject.Parse(responseContent); //JArray loi = (JArray)jObject.GetValue("categories"); //getresponse = loi.ToObject<List<Product>>(); } return(getresponse); }