public RideDetailModel GetRideDetails(string id, string username) { var request = HttpWebRequest.Create(string.Format(@"http://private-d1ca0-bunchyapi.apiary-mock.com/bunch/ridedetail/")); //var request = HttpWebRequest.Create(string.Format(@"http://192.168.56.1:1524/api/bunch/get/{0}", "townsville")); request.ContentType = "application/json"; request.Method = "GET"; using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { if (response.StatusCode != HttpStatusCode.OK) { Console.Out.WriteLine("Error fetching data. Server returned status code: {0}", response.StatusCode); } using (StreamReader reader = new StreamReader(response.GetResponseStream())) { var content = reader.ReadToEnd(); if (string.IsNullOrWhiteSpace(content)) { Console.Out.WriteLine("Response contained empty body..."); return(null); } else { Console.Out.WriteLine("Response Body: \r\n {0}", content); RideDetailModel _BunchDetailModel = JsonConvert.DeserializeObject <RideDetailModel>(content); return(_BunchDetailModel); } } } }
RideDetailModel GetRideDetail(string id) { IEnumerable <Account> accounts = AccountStore.Create(this).FindAccountsForService("google"); Account useraccount = accounts.FirstOrDefault(); BunchyServices _BunchyServices = new BunchyServices(); RideDetailModel _RideModel = new RideDetailModel(); _RideModel = _BunchyServices.GetRideDetails(id, useraccount.Username); return(_RideModel); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); string id = Intent.GetStringExtra("Id") ?? "Id not available"; SetContentView(Resource.Layout.RideDetail); RideDetailModel _RideDetailModel = new RideDetailModel(); _RideDetailModel = GetRideDetail(id); TextView DetailName = FindViewById <TextView> (Resource.Id.rideDetailName); DetailName.Text = _RideDetailModel.name; }