public async void getItinerary() { mainMapLayer = new MapLayer(); var result = await Request.RequestToServer.sendGetRequest("itineraries"); JObject jsonObject = JObject.Parse(result); string error = jsonObject.Value <string>("error").Trim(); //var xlong = jsonObject.SelectToken("itineraries"); JArray jsonVal = (JArray)jsonObject.SelectToken("itineraries"); //Convert json to object root = JsonConvert.DeserializeObject <RootObject>(result); foreach (Itinerary i in root.itineraries) { Global.GlobalData.itinearyList.Add(new Itinerary2 { itinerary_id = i.itinerary_id, driver_id = i.driver_id, customer_id = Convert.ToInt32(i.customer_id), start_address = i.start_address, start_address_lat = i.start_address_lat, start_address_long = i.start_address_long, end_address = i.end_address, end_address_lat = i.end_address_lat, end_address_long = i.end_address_long, pick_up_address = i.pick_up_address, pick_up_address_lat = i.pick_up_address_lat, pick_up_address_long = i.pick_up_address_long, drop_address = i.drop_address, drop_address_lat = i.drop_address_lat, drop_address_long = i.drop_address_long, cost = i.cost, distance = i.distance, description = i.description, duration = i.duration, status = i.status, created_at = i.created_at, leave_date = i.leave_date, driver_license = i.driver_license, driver_license_img = i.driver_license_img, user_id = i.user_id, email = i.email, fullname = i.fullname, phone = i.phone, personalID = i.personalID, //convert base64 to image link_avatar = ImageConvert.ImageConvert.convertBase64ToImage(i.link_avatar), average_rating = i.average_rating }); MapOverlay overlay = new MapOverlay(); overlay = MarkerDraw.DrawItineraryMarker(new GeoCoordinate(Convert.ToDouble(i.start_address_lat), Convert.ToDouble(i.start_address_long)), Global.GlobalData.itinearyList.Last()); //chua su dung //listMainMapOvelay.Add(overlay); mainMapLayer.Add(overlay); } mapMain.Layers.Add(mainMapLayer); longlistItineraries.ItemsSource = Global.GlobalData.itinearyList; }
public async void getItinerariesOfDriver() { //send get request string result = null; result = await Request.RequestToServer.sendGetRequest("itineraries/driver/itinerary_status"); RootObject root = JsonConvert.DeserializeObject <RootObject>(result); //xu ly json foreach (Itinerary i in root.itineraries) { Itinerary2 i2 = new Itinerary2 { itinerary_id = i.itinerary_id, driver_id = i.driver_id, customer_id = Convert.ToInt32(i.customer_id), start_address = i.start_address, start_address_lat = i.start_address_lat, start_address_long = i.start_address_long, end_address = i.end_address, end_address_lat = i.end_address_lat, end_address_long = i.end_address_long, pick_up_address = i.pick_up_address, pick_up_address_lat = i.pick_up_address_lat, pick_up_address_long = i.pick_up_address_long, drop_address = i.drop_address, drop_address_lat = i.drop_address_lat, drop_address_long = i.drop_address_long, cost = i.cost, distance = i.distance, description = i.description, duration = i.duration, status = i.status, created_at = i.created_at, leave_date = i.leave_date, driver_license = i.driver_license, driver_license_img = i.driver_license_img, user_id = i.user_id, email = i.email, fullname = i.fullname, phone = i.phone, personalID = i.personalID, //convert base64 to image link_avatar = ImageConvert.ImageConvert.convertBase64ToImage(i.link_avatar), average_rating = i.average_rating }; //itinearyList.Add(i2); if (i2.status == 1) { itinearyCreatedList.Add(i2); } else if (i2.status == 2) { itinearyCustomerAcceptedList.Add(i2); } else if (i2.status == 3) { itinearyDriverAcceptedList.Add(i2); } else if (i2.status == 4) { itinearyFinishedList.Add(i2); } else { //null } } //binding vao list //longlistItineraries.ItemsSource = itinearyList; longlistItinerariesCreated.ItemsSource = itinearyCreatedList; longlistItinerariesCustomerAccepted.ItemsSource = itinearyCustomerAcceptedList; longlistItinerariesDriverAccepted.ItemsSource = itinearyDriverAcceptedList; longlistItinerariesFinished.ItemsSource = itinearyFinishedList; }