private async void Okbtng_Clicked(object sender, EventArgs e)
        {
            ReservationController           reservationController = new ReservationController();
            CancelReservationMobileResponse response = null;



            bool busy = false;

            if (!busy)
            {
                try
                {
                    busy = true;
                    await PopupNavigation.Instance.PushAsync(new LoadingPopup("Cancelling Reservation"));

                    await Task.Run(() =>
                    {
                        response = reservationController.cancelReservation(cancelReservationMobileRequest, token);
                    });
                }
                finally
                {
                    busy = false;


                    if (response.ReservationNumber != null)
                    {
                        MessagingCenter.Send(this, "reservationCancelled");
                        await Navigation.PushAsync(new HomePage());
                    }
                    await PopupNavigation.Instance.PopAllAsync();
                }
            }
        }
        public CancelReservationMobileResponse cancelReservation(CancelReservationMobileRequest cancelReservation, string token)
        {
            CancelReservationMobileResponse result = null;

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

                    var myContent   = JsonConvert.SerializeObject(cancelReservation);
                    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 <CancelReservationMobileResponse>(responseStream);
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
        private async void cancelReservation(CancelReservationMobileRequest cancelReservationMobileRequest, string token)
        {
            ReservationController           reservationController = new ReservationController();
            CancelReservationMobileResponse response = null;

            bool cancelConfirm = await DisplayAlert("Alert", "Are you sure want to cancel reservation", "Confirm", "Back");

            if (cancelConfirm)
            {
                bool busy = false;
                if (!busy)
                {
                    try
                    {
                        busy = true;
                        await PopupNavigation.Instance.PushAsync(new LoadingPopup("Cancelling Reservation"));

                        await Task.Run(() =>
                        {
                            response = reservationController.cancelReservation(cancelReservationMobileRequest, token);
                        });
                    }
                    finally
                    {
                        busy = false;
                        await PopupNavigation.Instance.PopAllAsync();

                        if (response.ReservationNumber != null)
                        {
                            if (Navigation.NavigationStack[Navigation.NavigationStack.Count - 2].GetType() == typeof(SummaryOfChargesPage))
                            {
                                //int c = Navigation.NavigationStack.Count;
                                //for (var counter = 1; counter < c - 2; counter++)
                                //{
                                //    Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);

                                //}
                                await Navigation.PopModalAsync();
                            }

                            //if (Navigation.NavigationStack [Navigation.NavigationStack.Count - 1].GetType() == typeof(SummaryOfChargesPage))
                            //{
                            //    await Navigation.PushAsync(new HomePageDetail());
                            //}
                            else
                            {
                                await Navigation.PopModalAsync();
                            }
                        }
                    }
                }
            }
        }
        public CancelReservationMobileResponse cancelReservation(CancelReservationMobileRequest cancelReservation, string token)
        {
            CancelReservationMobileResponse mobileResponse = null;

            try
            {
                mobileResponse = reservationservice.cancelReservation(cancelReservation, token);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(mobileResponse);
        }
示例#5
0
        private async void Okbtng_Clicked(object sender, EventArgs e)
        {
            ReservationController           reservationController = new ReservationController();
            CancelReservationMobileResponse response = null;



            bool busy = false;

            if (!busy)
            {
                try
                {
                    busy = true;
                    await PopupNavigation.Instance.PushAsync(new LoadingPopup("Cancelling Reservation"));

                    await Task.Run(() =>
                    {
                        response = reservationController.cancelReservation(cancelReservationMobileRequest, token);
                    });
                }
                finally
                {
                    busy = false;

                    await PopupNavigation.Instance.PopAsync();

                    if (response != null)
                    {
                        if (response.message != null)
                        {
                            if (response.message.ErrorCode == "200")
                            {
                                if (response.refundStatus)
                                {
                                    if (response.ReservationNumber != null)
                                    {
                                        await PopupNavigation.Instance.PushAsync(new SuccessPopUp("Your reservation has been successfully cancelled. The balance of your payment will be refunded shortly.", 1));
                                    }
                                    else
                                    {
                                        await PopupNavigation.Instance.PushAsync(new Error_popup("Something went wrong, Please contact administrator to cancel your booking. ", 2));
                                    }
                                }
                                else
                                {
                                    if (response.ReservationNumber != null)
                                    {
                                        await PopupNavigation.Instance.PushAsync(new SuccessPopUp("Your reservation has been successfully cancelled. The balance of your payment will be refunded shortly. ", 1));
                                    }
                                    else
                                    {
                                        await PopupNavigation.Instance.PushAsync(new Error_popup("Something went wrong, Please contact administrator to cancel your booking. ", 2));
                                    }
                                }
                            }
                            else
                            {
                                await PopupNavigation.Instance.PushAsync(new Error_popup(response.message.ErrorMessage, 2));
                            }
                        }
                        else
                        {
                            await PopupNavigation.Instance.PushAsync(new Error_popup("Something went wrong, Please try again", 2));
                        }
                    }
                    else
                    {
                        await PopupNavigation.Instance.PushAsync(new Error_popup("Something went wrong, Please try again", 2));
                    }
                }
            }
        }