public ProcessPaymentPage(decimal balanceDue, int agreementId, int locationIdForPayment, AgreementReview agreementReview, ExtendAgreementRequest request)
 {
     InitializeComponent();
     this.balanceDue           = balanceDue;
     amountLAbel.Text          = "$ " + balanceDue.ToString("0.00");
     creditCardRequest         = new GetAllCustomerMobileCreditCardRequest();
     creditCards               = null;
     customerId                = (int)App.Current.Properties["CustomerId"];
     token                     = App.Current.Properties["currentToken"].ToString();
     billingInformation        = new BillingInformation();
     PaymentResponse           = null;
     this.agreementId          = agreementId;
     this.locationIdForPayment = locationIdForPayment;
     this.agreementReview      = agreementReview;
     submitPaymentAndExtendAgreementRequest = new SubmitPaymentAndExtendAgreementRequest();
     if (agreementReview != null)
     {
         isExtendAgreement = true;
     }
     else if (agreementReview == null)
     {
         isExtendAgreement = false;
     }
     promotionMobileRequest  = new GetPromotionMobileRequest();
     promotionMobileResponse = null;
     appliedPromoId          = 0;
     extendAgreemetRequest   = request;
     extendAgreementResponse = null;
 }
Exemple #2
0
 public VehicleRates(ReservationView reservationView, VehicleViewByTypeForMobile selectedVehicle)
 {
     InitializeComponent();
     this.reservationView = reservationView;
     //misChargeFilter = new MisChargeFilter();
     misChargeRequest = new GetMischargeSearchDetailsMobileRequest();
     //taxFilter = new TaxFilter();
     taxRequest             = new GetTaxMobileListRequest();
     promotionMobileRequest = new GetPromotionMobileRequest();
     //misChargeFilter.LocationId =(int) reservationView.StartLocationId;
     //misChargeFilter.VehicleTypeId =(int) reservationView.VehicleTypeID;
     misChargeRequest.LocationId    = (int)reservationView.StartLocationId;
     misChargeRequest.VehicleTypeId = (int)reservationView.VehicleTypeID;
     //taxFilter.LocationId = (int)reservationView.StartLocationId;
     taxRequest.LocationId   = (int)reservationView.StartLocationId;
     promotionMobileResponse = null;
     misChargeResults        = null;
     misChargeResponse       = null;
     taxResults            = null;
     taxResponse           = null;
     reservationController = new ReservationController();
     token = App.Current.Properties["currentToken"].ToString();
     this.selectedVehicle = selectedVehicle;
     startDateLabel.Text  = ((DateTime)reservationView.StartDate).ToString("ddd MM/dd/yyyy");
     endDateLabel.Text    = ((DateTime)reservationView.EndDate).ToString("ddd MM/dd/yyyy");
     startTimeLabel.Text  = ((DateTime)reservationView.StartDate).ToString("hh:mm tt");
     endTimeLabel.Text    = ((DateTime)reservationView.EndDate).ToString("hh:mm tt");
     if (selectedVehicle.VehicleTypeImageUrl != null)
     {
         vehilcleTypeImage.Source = ImageSource.FromUri(new Uri(selectedVehicle.VehicleTypeImageUrl));
     }
     vehicleSampleLabel.Text = selectedVehicle.sample;
     vehilcleTypeLabel.Text  = selectedVehicle.VehicleType;
     priceLabel.Text         = "$ " + selectedVehicle.RateDetail.RateTotal.ToString();
 }
        public GetPromotionMobileResponse checkPromotion(GetPromotionMobileRequest promotionMobileRequest, string token)
        {
            GetPromotionMobileResponse result = null;

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(ConstantData.ApiURL.ToString() + "PromotionMobile/GetSearchPromotionMobile");
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

                    var myContent   = JsonConvert.SerializeObject(promotionMobileRequest);
                    var buffer      = Encoding.UTF8.GetBytes(myContent);
                    var byteContent = new ByteArrayContent(buffer);
                    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");



                    var response = client.PostAsync(client.BaseAddress, byteContent).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        var responseStream = response.Content.ReadAsStringAsync().Result;
                        result = JsonConvert.DeserializeObject <GetPromotionMobileResponse>(responseStream);
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Exemple #4
0
        private async void PromoBtn_Clicked(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(promoCodeEntry.Text))
            {
                promotionMobileRequest.PromotionCode = promoCodeEntry.Text;
                promotionMobileRequest.LocationId    = (int)reservationView.StartLocationId;
                promotionMobileRequest.VehicleTypeId = (int)reservationView.VehicleTypeID;

                bool busy = false;
                if (!busy)
                {
                    try
                    {
                        busy = true;
                        await PopupNavigation.Instance.PushAsync(new LoadingPopup("Checking for promotion..."));

                        await Task.Run(() =>
                        {
                            try
                            {
                                promotionMobileResponse = reservationController.checkPromotion(promotionMobileRequest, token);
                            }
                            catch (Exception ex)
                            {
                                PopupNavigation.Instance.PushAsync(new ErrorWithClosePagePopup(ex.Message));
                            }
                        });
                    }
                    finally
                    {
                        busy = false;
                        if (PopupNavigation.Instance.PopupStack.Count == 1)
                        {
                            await PopupNavigation.Instance.PopAllAsync();
                        }
                        if (PopupNavigation.Instance.PopupStack.Count > 1)
                        {
                            if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() != typeof(ErrorWithClosePagePopup))
                            {
                                await PopupNavigation.Instance.PopAllAsync();
                            }
                        }
                    }
                    if (promotionMobileResponse.promotion == null)
                    {
                        await PopupNavigation.Instance.PushAsync(new Error_popup("Invalid promo code"));
                    }
                    else
                    {
                        await PopupNavigation.Instance.PushAsync(new SuccessPopUp("Promo code successfully added."));

                        reservationView.PromotionCode = promoCodeEntry.Text;
                    }
                }
            }
        }
        private void applyAgreementPromotion(GetPromotionMobileResponse promotionMobileResponse)
        {
            extendAgreemetRequest.addPromotion = new PromotionItem()
            {
                PromotionID = promotionMobileResponse.PromResult.PromotionID, PromotionDiscount = (decimal)promotionMobileResponse.PromResult.DiscountValue, PromotionCode = promotionMobileResponse.promotion.PromotionCode
            };
            extendAgreemetRequest.deletePromotion = null;
            promoTitileLabel.Text = promotionMobileResponse.promotion.PromotionCode;
            promoDetailLabel.Text = "$" + promotionMobileResponse.promotion.DiscountValue.ToString("0.00");
            appliedPromoId        = promotionMobileResponse.PromResult.PromotionID;
            hideAddPromotionGrid();
            AgreementController controller = new AgreementController();

            try
            {
                extendAgreementResponse = controller.extendAgreement(extendAgreemetRequest, token);
            }

            finally
            {
                if (extendAgreementResponse != null)
                {
                    if (extendAgreementResponse.message != null)
                    {
                        if (extendAgreementResponse.message.ErrorCode == "200")
                        {
                            balanceDue = (decimal)extendAgreementResponse.agreementReview.BalanceDue;
                            if (balanceDue <= 0)
                            {
                                balanceDue = 0;
                            }
                            agreementReview  = extendAgreementResponse.agreementReview;
                            amountLAbel.Text = "$ " + balanceDue.ToString("0.00");

                            foreach (PromotionItem p in extendAgreementResponse.agreementReview.PromotionList)
                            {
                                if (p.PromotionID == appliedPromoId)
                                {
                                    promoDetailLabel.Text = "$" + p.PromotionDiscount.ToString("0.00");
                                }
                            }

                            int ordNo = 1;
                            foreach (PromotionItem p1 in agreementReview.PromotionList)
                            {
                                p1.PromotionListId = ordNo;
                                ordNo += 1;
                            }
                        }
                    }
                }
            }
        }
        public GetPromotionMobileResponse checkPromotion(GetPromotionMobileRequest promotionMobileRequest, string token)
        {
            GetPromotionMobileResponse mobileResponse = null;

            try
            {
                mobileResponse = reservationservice.checkPromotion(promotionMobileRequest, token);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(mobileResponse);
        }
 public ProcessPaymentPage(decimal amountWantToPay, ReservationView reservationView)
 {
     InitializeComponent();
     this.amountWantToPay = amountWantToPay;
     this.reservationView = reservationView;
     amountLAbel.Text     = "$ " + amountWantToPay.ToString("0.00");
     creditCardRequest    = new GetAllCustomerMobileCreditCardRequest();
     creditCards          = null;
     customerId           = (int)App.Current.Properties["CustomerId"];
     token = App.Current.Properties["currentToken"].ToString();
     billingInformation = new BillingInformation();
     PaymentResponse    = null;
     agreementId        = 0;
     submitPaymentAndUpDateReservationRequest = new SubmitPaymentAndUpDateReservationRequest();
     paynowBtn.Text          = "Pay and extend now";
     isExtendAgreement       = false;
     promotionMobileRequest  = new GetPromotionMobileRequest();
     promotionMobileResponse = null;
     summaryMobileRequest    = new GetCalculateSummaryMobileRequest();
     summaryMobileResponsecs = null;
     appliedPromoId          = 0;
 }
Exemple #8
0
 public EditVehicleRates(ReservationView reservationView, ReservationViewModel reservationData)
 {
     InitializeComponent();
     this.reservationView = reservationView;
     //misChargeFilter = new MisChargeFilter();
     misChargeRequest = new GetMischargeSearchDetailsMobileRequest();
     //taxFilter = new TaxFilter();
     taxRequest             = new GetTaxMobileListRequest();
     promotionMobileRequest = new GetPromotionMobileRequest();
     //misChargeFilter.LocationId =(int) reservationView.StartLocationId;
     //misChargeFilter.VehicleTypeId =(int) reservationView.VehicleTypeID;
     misChargeRequest.LocationId    = (int)reservationView.StartLocationId;
     misChargeRequest.VehicleTypeId = (int)reservationView.VehicleTypeID;
     //taxFilter.LocationId = (int)reservationView.StartLocationId;
     taxRequest.LocationId   = (int)reservationView.StartLocationId;
     promotionMobileResponse = null;
     misChargeResults        = null;
     misChargeResponse       = null;
     taxResults            = null;
     taxResponse           = null;
     reservationController = new ReservationController();
     token = App.Current.Properties["currentToken"].ToString();
     this.reservationData = reservationData;
 }
        private void applyReservationPromotion(GetPromotionMobileResponse promotionMobileResponse)
        {
            promoTitileLabel.Text = promotionMobileResponse.promotion.PromotionCode;
            promoDetailLabel.Text = "$" + promotionMobileResponse.promotion.DiscountValue.ToString("0.00");
            appliedPromoId        = promotionMobileResponse.PromResult.PromotionID;
            hideAddPromotionGrid();

            reservationView.PromotionCode = promoCodeEntry.Text;
            reservationView.PromotionList.Add(new PromotionItem()
            {
                PromotionID = promotionMobileResponse.PromResult.PromotionID, PromotionDiscount = (decimal)promotionMobileResponse.PromResult.DiscountValue
            });

            summaryMobileRequest.reservation = reservationView;
            try
            {
                try
                {
                    summaryMobileResponsecs = getSummaryDetails(summaryMobileRequest, token);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            finally
            {
                //amountWantToPay
                decimal amountWant = 0;
                if (summaryMobileResponsecs.rate.ReservationSummary.EstimatedTotal == null)
                {
                    amountWant = (decimal)summaryMobileResponsecs.rate.EstimatedTotal - reservationView.AdvancedPayment;
                }
                else
                {
                    amountWant = Convert.ToDecimal(summaryMobileResponsecs.rate.ReservationSummary.EstimatedTotal) - reservationView.AdvancedPayment;
                }

                if (amountWant > 0)
                {
                    amountWantToPay = amountWant;
                }
                else
                {
                    amountWantToPay = 0;
                }


                amountLAbel.Text = "$ " + amountWantToPay.ToString("0.00");


                int ordNo = 1;
                foreach (PromotionItem p1 in reservationView.PromotionList)
                {
                    p1.PromotionListId = ordNo;
                    ordNo += 1;
                }


                foreach (PromotionItem p in summaryMobileResponsecs.rate.ReservationSummary.PromotionList)
                {
                    if (p.PromotionID == appliedPromoId)
                    {
                        promoDetailLabel.Text = "$" + p.PromotionDiscount.ToString("0.00");
                    }
                }


                reservationView.BasePrice               = Convert.ToDecimal(summaryMobileResponsecs.rate.ReservationSummary.FinalBaseRate);
                reservationView.PreSubTotal             = Convert.ToDecimal(summaryMobileResponsecs.rate.ReservationSummary.PreSubTotal);
                reservationView.TotalDiscountOnBaseRate = Convert.ToDecimal(summaryMobileResponsecs.rate.ReservationSummary.PromoDiscountOnBaseRate);
                reservationView.TotalDiscount           = Convert.ToDecimal(summaryMobileResponsecs.rate.ReservationSummary.PromoDiscountOnBaseRate);
                reservationView.TotalDiscountOnSubTotal = Convert.ToDecimal(summaryMobileResponsecs.rate.ReservationSummary.PromoDiscountOnSubtotal);
            }
        }
        async void PromoBtn_Clicked(System.Object sender, System.EventArgs e)
        {
            if (!string.IsNullOrEmpty(promoCodeEntry.Text))
            {
                promotionMobileRequest.PromotionCode = promoCodeEntry.Text;
                promotionMobileRequest.LocationId    = !isExtendAgreement ? (int)reservationView.StartLocationId : 0;
                promotionMobileRequest.VehicleTypeId = !isExtendAgreement ? (int)reservationView.VehicleTypeID : 0;

                bool busy = false;
                if (!busy)
                {
                    try
                    {
                        busy = true;
                        await PopupNavigation.Instance.PushAsync(new LoadingPopup("Checking for promotion..."));

                        ReservationController reservationController = new ReservationController();
                        await Task.Run(() =>
                        {
                            try
                            {
                                promotionMobileResponse = reservationController.checkPromotion(promotionMobileRequest, token);
                            }
                            catch (Exception ex)
                            {
                                PopupNavigation.Instance.PushAsync(new ErrorWithClosePagePopup(ex.Message));
                            }
                        });
                    }
                    finally
                    {
                        busy = false;
                        if (PopupNavigation.Instance.PopupStack.Count == 1)
                        {
                            await PopupNavigation.Instance.PopAllAsync();
                        }
                        if (PopupNavigation.Instance.PopupStack.Count > 1)
                        {
                            if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() != typeof(ErrorWithClosePagePopup))
                            {
                                await PopupNavigation.Instance.PopAllAsync();
                            }
                        }
                    }
                    if (promotionMobileResponse.promotion == null)
                    {
                        await PopupNavigation.Instance.PushAsync(new Error_popup("Invalid promo code"));
                    }
                    else
                    {
                        if (promotionMobileResponse.promotion.StartDate <= DateTime.Now && DateTime.Now <= promotionMobileResponse.promotion.EndDate)
                        {
                            if (!isExtendAgreement)
                            {
                                if (reservationView.PromotionList == null)
                                {
                                    await PopupNavigation.Instance.PushAsync(new SuccessPopUp("Promo code has been applied successfully!"));

                                    reservationView.PromotionList = new List <PromotionItem>();
                                    applyReservationPromotion(promotionMobileResponse);
                                }
                                else
                                {
                                    var alreadyAppliedPromos = reservationView.PromotionList.FindAll(m => m.PromotionID == promotionMobileResponse.promotion.PromotionID);
                                    if (alreadyAppliedPromos.Count > 0)
                                    {
                                        await PopupNavigation.Instance.PushAsync(new Error_popup("Invalid promo code"));
                                    }
                                    else
                                    {
                                        await PopupNavigation.Instance.PushAsync(new SuccessPopUp("Promo code has been applied successfully!"));

                                        applyReservationPromotion(promotionMobileResponse);
                                    }
                                }
                            }
                            else
                            {
                                if (agreementReview.PromotionList != null)
                                {
                                    var alreadyAppliedAgreePromos = agreementReview.PromotionList.FindAll(m => m.PromotionID == promotionMobileResponse.promotion.PromotionID);
                                    if (alreadyAppliedAgreePromos.Count > 0)
                                    {
                                        await PopupNavigation.Instance.PushAsync(new Error_popup("Invalid promo code"));
                                    }
                                    else
                                    {
                                        await PopupNavigation.Instance.PushAsync(new SuccessPopUp("Promo code has been applied successfully!"));

                                        applyAgreementPromotion(promotionMobileResponse);
                                    }
                                }
                                else
                                {
                                    await PopupNavigation.Instance.PushAsync(new SuccessPopUp("Promo code has been applied successfully!"));

                                    applyAgreementPromotion(promotionMobileResponse);
                                }
                            }
                        }
                        else
                        {
                            await PopupNavigation.Instance.PushAsync(new Error_popup("Invalid promo code"));
                        }
                    }
                }
            }
        }