public GetStoreHoursMobileResponse getStoreHoursMobile(GetStoreHoursMobileRequest getStoreHoursMobileRequest, string token)
        {
            GetStoreHoursMobileResponse result = null;

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

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

            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
        public GetStoreHoursMobileResponse getStoreHoursMobile(GetStoreHoursMobileRequest getStoreHoursMobileRequest, string _token)
        {
            GetStoreHoursMobileResponse mobileResponse = null;

            try
            {
                mobileResponse = reservationservice.getStoreHoursMobile(getStoreHoursMobileRequest, _token);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(mobileResponse);
        }
 public BookNow(ReservationView reservationView, VehicleViewByTypeForMobile selectedVehicle, List <int> locationIdList)
 {
     InitializeComponent();
     vehicleMobileRequest  = new GetReservationConfigurationMobileRequest();
     vehicleMobileResponse = null;
     search = new ReservationConfigurationVehicleSearch();
     //locationModels = null;
     locationResponse            = null;
     getStoreHoursMobileResponse = null;
     getStoreHoursMobileRequest  = new GetStoreHoursMobileRequest();
     reservationView             = new ReservationView();
     customerId           = 0;
     isBookable           = true;
     this.reservationView = reservationView;
     this.selectedVehicle = selectedVehicle;
     this.locationIdList  = locationIdList;
 }
        private void BookNowNxtBtn_Clicked(object sender, EventArgs e)
        {
            DateTime pickupDateTime = pickUpDate.Date + pickUpTime.Time;

            //if (pickupDateTime < DateTime.Now)
            //{
            //    PopupNavigation.Instance.PushAsync(new Error_popup("Plese check your pick-up time."));
            //}

            //else
            if (pickUpLocation.SelectedIndex == -1)
            {
                PopupNavigation.Instance.PushAsync(new Error_popup("Please select a pick-up location"));
            }
            //else if (DateTime.Now.AddHours(36) <= pickupDateTime)
            //{
            //    PopupNavigation.Instance.PushAsync(new Error_popup("Your pick up time may be no more than 36 hours from now"));
            //}
            else if (NumberOfDays.SelectedIndex == -1)
            {
                PopupNavigation.Instance.PushAsync(new Error_popup("Please select the number of days for your initial booking. You may extend your rental at any time"));
            }

            else
            {
                DateTime DropOffDateTime = pickupDateTime.AddDays(int.Parse(NumberOfDays.SelectedItem.ToString()));
                int      locId           = getLocationIdByName(pickUpLocation.SelectedItem.ToString());
                getStoreHoursMobileRequest.locationId = locId;
                try
                {
                    ReservationController reservationController = new ReservationController();
                    getStoreHoursMobileResponse = reservationController.getStoreHoursMobile(getStoreHoursMobileRequest, _token);
                }
                catch (Exception ex)
                {
                    PopupNavigation.Instance.PushAsync(new Error_popup(ex.Message));
                }
                if (getStoreHoursMobileResponse != null)
                {
                    if (getStoreHoursMobileResponse.storeHourModels != null)
                    {
                        if (getStoreHoursMobileResponse.storeHourModels.Count > 0)
                        {
                            bool      isPickUpStoreTime   = true;
                            bool      isDropOffStoreTime  = true;
                            bool      isPickUpNonHoliday  = true;
                            bool      isDropOffNonHoliday = true;
                            DayOfWeek date = (pickUpDate.Date + pickUpTime.Time).DayOfWeek;

                            foreach (SearchStoreHourModel sshm in getStoreHoursMobileResponse.storeHourModels)
                            {
                                if ((pickUpDate.Date + pickUpTime.Time).DayOfWeek.ToString() == Enum.GetName(typeof(DayOfWeek), sshm.Day - 1))
                                {
                                    if (((DateTime)sshm.StartTime).TimeOfDay <= pickUpTime.Time && pickUpTime.Time <= ((DateTime)sshm.EndTime).AddHours(-1).TimeOfDay)
                                    {
                                        if (sshm.IsHoliday)
                                        {
                                            isPickUpNonHoliday = false;
                                            PopupNavigation.Instance.PushAsync(new Error_popup("Sorry, the date you selected is a holiday. Please choose another pick up date"));
                                        }
                                        else
                                        {
                                            isPickUpNonHoliday = true;
                                            isPickUpStoreTime  = true;
                                        }
                                    }
                                    else
                                    {
                                        isPickUpStoreTime = false;
                                        PopupNavigation.Instance.PushAsync(new Error_popup("Our business hours are " + ((DateTime)sshm.StartTime).ToString("hh:mm tt") + " to " + (((DateTime)sshm.EndTime).AddHours(-1)).ToString("hh:mm tt") + ". Please select a pick up time within those hours."));
                                    }
                                }



                                //if ((DropOffDateTime).DayOfWeek.ToString() == Enum.GetName(typeof(DayOfWeek), sshm.Day-1))
                                //{
                                //    if (((DateTime)sshm.StartTime).TimeOfDay <= DropOffDateTime.TimeOfDay && DropOffDateTime.TimeOfDay <= ((DateTime)sshm.EndTime).TimeOfDay)
                                //    {

                                //        //if (sshm.IsHoliday)
                                //        //{
                                //        //    isDropOffNonHoliday = false;
                                //        //    PopupNavigation.Instance.PushAsync(new Error_popup("Sorry,your drop off date is a holiday. please choose another Drop-off date"));
                                //        //}
                                //        //else
                                //        //{
                                //        //    isDropOffNonHoliday = true;
                                //        //    isDropOffStoreTime = true;
                                //        //}

                                //        isDropOffNonHoliday = true;
                                //        isDropOffStoreTime = true;
                                //    }
                                //    else
                                //    {
                                //        isDropOffStoreTime = false;
                                //        PopupNavigation.Instance.PushAsync(new Error_popup("Sorry, we are only open during " + sshm.StartTimeStr + " to " + sshm.EndTimeStr + " Please select a different drop off time"));
                                //    }
                                //}
                            }
                            if (isPickUpStoreTime && isDropOffStoreTime && isPickUpNonHoliday && isDropOffNonHoliday)
                            {
                                navigateNextPage();
                            }
                        }
                        else
                        {
                            navigateNextPage();
                        }
                    }
                    else
                    {
                        navigateNextPage();
                    }
                }
                else
                {
                    navigateNextPage();
                }
            }
        }