Beispiel #1
0
		protected override bool IsValid(PropertyValidatorContext context) {
			String pcode = context.PropertyValue.ToString ();

			var dic = new Dictionary<String, String> {
				{ Constant.VALIDATEDISCOUNTCOUPON_CODE, pcode },
				{ Constant.VALIDATEDISCOUNTCOUPON_CUSTOMERID, "-1" },
				{ Constant.VALIDATEDISCOUNTCOUPON_EMAIL, "" },
				{ Constant.VALIDATEDISCOUNTCOUPON_SERVICEID, "-1" },
				{ Constant.VALIDATEDISCOUNTCOUPON_TRAVELDATE, "" },
				{ Constant.VALIDATEDISCOUNTCOUPON_VALIDATIONTYPE, "1" }
			};

			string result;
			ValidateDiscountCouponResponse tt = null;
			try {
				UserTrackingReporter.TrackUser (Constant.CATEGORY_PROMO_CODE, "Validating promo code");

				Task runSync = Task.Factory.StartNew (async () => {
					result = await AppData.ApiCall (Constant.VALIDATEDISCOUNTCOUPON, dic);
					tt = (ValidateDiscountCouponResponse)AppData.ParseResponse (Constant.VALIDATEDISCOUNTCOUPON, result);
				}).Unwrap ();
				runSync.Wait ();

			} catch (Exception ex) {
				CrashReporter.Report (ex);
				return false;
			}
			if (tt == null || String.IsNullOrEmpty (tt.Result) || tt.Result.ToLower ().Contains ("failed")) {
				UserTrackingReporter.TrackUser (Constant.CATEGORY_PROMO_CODE, "Invalid promo code entered");
				return false;
			}
			return true;
		}
Beispiel #2
0
        private void VerifyPromoCode()
        {
            mActivity.ShowLoadingView("Veryfying promo code");
            var dic = new Dictionary <String, String> {
                { Constant.VALIDATEDISCOUNTCOUPON_CODE, mPromoCode.Text },
                { Constant.VALIDATEDISCOUNTCOUPON_CUSTOMERID, "-1" },
                { Constant.VALIDATEDISCOUNTCOUPON_EMAIL, "" },
                { Constant.VALIDATEDISCOUNTCOUPON_SERVICEID, "-1" },
                { Constant.VALIDATEDISCOUNTCOUPON_TRAVELDATE, "" },
                { Constant.VALIDATEDISCOUNTCOUPON_VALIDATIONTYPE, "1" }
            };

            string result;
            ValidateDiscountCouponResponse tt = null;

            try
            {
                UserTrackingReporter.TrackUser(Constant.CATEGORY_PROMO_CODE, "Validating promo code");

                Task runSync = Task.Factory.StartNew(async() =>
                {
                    result = await AppData.ApiCall(Constant.VALIDATEDISCOUNTCOUPON, dic);
                    tt     = (ValidateDiscountCouponResponse)AppData.ParseResponse(Constant.VALIDATEDISCOUNTCOUPON, result);
                }).Unwrap();
                runSync.Wait();
            }
            catch (Exception ex)
            {
                CrashReporter.Report(ex);
                mActivity.HideLoadingView();
                mActivity.RunOnUiThread(() =>
                {
                    mActivity.ShowMessageBox("Failed", "Invalid promo code entered.");
                });
            }
            if (tt == null || String.IsNullOrEmpty(tt.Result) || tt.Result.ToLower().Contains("failed"))
            {
                UserTrackingReporter.TrackUser(Constant.CATEGORY_PROMO_CODE, "Invalid promo code entered");
                mActivity.RunOnUiThread(() =>
                {
                    mActivity.ShowMessageBox("Failed", "Invalid promo code entered.");
                });
            }
            else
            {
                mActivity.RunOnUiThread(() =>
                {
                    mActivity.ShowMessageBox("Success", "Valid promo code entered.");
                });
            }
            mActivity.HideLoadingView();
        }