예제 #1
0
		/// <summary>
		/// Gets the trip detail. Excludes properties of BookingEntry; This is used to streamline the passing of data to the API
		/// </summary>
		/// <returns>The trip detail.</returns>
		//[XmlInclude(typeof(BookingEntry))]
		public TripDetail GetTripDetail ()
		{
			TripDetail result = new TripDetail ();

			Type bookingType = base.GetType ();

			var properties = bookingType.GetProperties ().Where (p => p.DeclaringType == typeof(TripDetail));
			foreach (PropertyInfo propertyInfo in properties) {
				if (propertyInfo.CanRead) {
					object bookingValue = propertyInfo.GetValue (this, null);
					object tripDetailValue = propertyInfo.GetValue (result, null);
					if (!object.Equals (bookingValue, tripDetailValue)) {
						propertyInfo.SetValue (result, bookingValue, null);
					}
				}
			}
			return result;
		}
예제 #2
0
		public TripClient UpdateAsync (TripDetail tripDetail)
		{
			return InvokeStrategy<TripClient> (() => {

				if (base.PostObjectAsync (UrlPaths.Update, tripDetail, UpdateTripCompleted).HasErrors)
					return;
			});			
		}
예제 #3
0
		/// <summary>
		/// Merges the TripDetail returned from the API with the BookingEntry object used for the current booking.
		/// </summary>
		/// <returns>The atlas to mobile.</returns>
		public static BookingEntry MergeWithApi (BookingEntry mobile, TripDetail api)
		{
			//start with the api version since it has more properties
			Type apiType = api.GetType ();

			var properties = apiType.GetProperties ().Where (p => p.DeclaringType == typeof(TripDetail));
			foreach (PropertyInfo propertyInfo in properties) {

				if (propertyInfo.CanRead) {
					object apiValue = propertyInfo.GetValue (api, null);
					object bookingEntryValue = propertyInfo.GetValue (mobile, null);
					if (!object.Equals (apiValue, bookingEntryValue) && !apiValue.IsEmpty ()) {

						propertyInfo.SetValue (mobile, apiValue, null);
					}
				}

			}

			return mobile;

		}
예제 #4
0
		public TripClient GetRecommendedPickupTime (TripDetail trip, bool async = false)
		{

			return InvokeStrategy<TripClient> (() => {
				// need to nullify pickup time (in case it has a value) for recommendation to work
				trip.PickupDate = "";
				trip.PickupHour = "";
				trip.PickupMinutes = "";
				trip.PickupAmPm = "";

				if (async) {
					if (base.PostObjectAsync (UrlPaths.GetRecommendedPickupTime, trip, GetRecommendedPickupTimeCompleted).HasErrors)
						return;
				} else {
					if (base.PostObject (UrlPaths.GetRecommendedPickupTime, trip).HasErrors)
						return;

					GetRecommendedPickupTimeCompleted ();
				}
			});
		}