public GetAllLocationForClientIDForMobileResponse getAllLocationsByClientId(GetAllLocationForClientIDForMobileRequest locationRequest, string token) { GetAllLocationForClientIDForMobileResponse resp = null; try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(ConstantData.ApiURL.ToString() + "CommonMobile/GetAllLocationForClientIDForMobile"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var myContent = JsonConvert.SerializeObject(locationRequest); var buffer = System.Text.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; resp = JsonConvert.DeserializeObject <GetAllLocationForClientIDForMobileResponse>(responseStream); } } } catch (Exception ex) { throw ex; } return(resp); }
public GetAllLocationForClientIDForMobileResponse getAllLocationsByClientId(GetAllLocationForClientIDForMobileRequest locationRequest, string token) { GetAllLocationForClientIDForMobileResponse locations = null; try { locations = commonService.getAllLocationsByClientId(locationRequest, token); } catch (Exception ex) { throw ex; } return(locations); }
private GetAllLocationForClientIDForMobileResponse getAllLocationsByClientId(GetAllLocationForClientIDForMobileRequest locationRequest, string _token) { CommonController commoncontroller = new CommonController(); GetAllLocationForClientIDForMobileResponse locations = null; try { locations = commoncontroller.getAllLocationsByClientId(locationRequest, _token); } catch (Exception ex) { throw ex; } return(locations); }
protected override async void OnAppearing() { base.OnAppearing(); var assembly = typeof(BookNow); if (PopupNavigation.Instance.PopupStack.Count > 0) { if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() == typeof(ErrorWithClosePagePopup)) { await PopupNavigation.Instance.PopAllAsync(); } } _token = App.Current.Properties["currentToken"].ToString(); if ((int)App.Current.Properties["CustomerId"] > 0) { customerId = (int)App.Current.Properties["CustomerId"]; } GetAllLocationForClientIDForMobileRequest locationRequest = new GetAllLocationForClientIDForMobileRequest(); locationRequest.ClientID = Constants.ClientId; bool busy = false; if (!busy) { try { busy = true; await PopupNavigation.Instance.PushAsync(new LoadingPopup("Creating book now page...")); await Task.Run(async() => { try { locationResponse = getAllLocationsByClientId(locationRequest, _token); if (customerId > 0) { isBookable = checkBookable(); } } catch (Exception ex) { await PopupNavigation.Instance.PushAsync(new ErrorWithClosePagePopup(ex.Message)); } }); } finally { busy = false; if (PopupNavigation.Instance.PopupStack.Count == 1) { await PopupNavigation.Instance.PopAllAsync(); } else if (PopupNavigation.Instance.PopupStack.Count > 1) { if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() != typeof(ErrorWithClosePagePopup)) { await PopupNavigation.Instance.PopAllAsync(); } } if (!isBookable) { await PopupNavigation.Instance.PushAsync(new Error_popup("You already have an active reservation. You may only reserve one vehicle at a time", true)); } } if (locationResponse != null) { locationNames = new List <string>(); foreach (LocationModel l in locationResponse.locationList) { if ((bool)l.Active && selectedVehicle.locationIdList.Contains((int)l.LocationId)) { locationNames.Add(l.LocationName); } } pickUpLocation.ItemsSource = locationNames; //dropOffLocation.ItemsSource = locationNames; } else { await Navigation.PopAsync(); } pickUpDate.Date = DateTime.Now; pickUpDate.MaximumDate = DateTime.Now.AddDays(1); pickUpDate.MinimumDate = DateTime.Now; pickUpDate.Date = DateTime.Now.AddDays(1); //pickUpTime.Time = new TimeSpan(DateTime.Now.TimeOfDay.Add(new TimeSpan(12, 0, 0)).Hours, DateTime.Now.TimeOfDay.Add(new TimeSpan(12, 0, 0)).Minutes, DateTime.Now.TimeOfDay.Add(new TimeSpan(12, 0, 0)).Seconds); //dropOffDate.Date = DateTime.Now.AddDays(1); //dropOffDate.MinimumDate = DateTime.Now; //dropOffTime.Time = new TimeSpan(9, 0, 0); } }
protected override async void OnAppearing() { base.OnAppearing(); var assembly = typeof(BookNow); if (PopupNavigation.Instance.PopupStack.Count > 0) { if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() == typeof(ErrorWithClosePagePopup)) { await PopupNavigation.Instance.PopAllAsync(); } } _token = App.Current.Properties["currentToken"].ToString(); if ((int)App.Current.Properties["CustomerId"] == 0) { loginIcon.IconImageSource = ImageSource.FromResource("NativeCamperVans.Assets.LogInTool.png", assembly); } else { loginIcon.IconImageSource = ImageSource.FromResource("NativeCamperVans.Assets.logOutTool.png", assembly); } GetAllLocationForClientIDForMobileRequest locationRequest = new GetAllLocationForClientIDForMobileRequest(); locationRequest.ClientID = Constants.ClientId; bool busy = false; if (!busy) { try { busy = true; await PopupNavigation.Instance.PushAsync(new LoadingPopup("Creating book now page...")); await Task.Run(async() => { try { locationResponse = getAllLocationsByClientId(locationRequest, _token); } catch (Exception ex) { await PopupNavigation.Instance.PushAsync(new ErrorWithClosePagePopup(ex.Message)); } }); } finally { busy = false; if (PopupNavigation.Instance.PopupStack.Count == 1) { await PopupNavigation.Instance.PopAllAsync(); } else if (PopupNavigation.Instance.PopupStack.Count > 1) { if (PopupNavigation.Instance.PopupStack[PopupNavigation.Instance.PopupStack.Count - 1].GetType() != typeof(ErrorWithClosePagePopup)) { await PopupNavigation.Instance.PopAllAsync(); } } } if (locationResponse != null) { locationNames = new List <string>(); foreach (LocationModel l in locationResponse.locationList) { locationNames.Add(l.LocationName); } pickUpLocation.ItemsSource = locationNames; dropOffLocation.ItemsSource = locationNames; } else { await Navigation.PopAsync(); } pickUpDate.MinimumDate = DateTime.Now; pickUpDate.Date = DateTime.Now; pickUpTime.Time = new TimeSpan(9, 0, 0); dropOffDate.Date = DateTime.Now.AddDays(1); dropOffDate.MinimumDate = DateTime.Now; dropOffTime.Time = new TimeSpan(9, 0, 0); pickUpDate.Date = DateTime.Parse(reservationData.Reservationview.StartDateStr); dropOffDate.Date = DateTime.Parse(reservationData.Reservationview.EndDateStr); pickUpLocation.SelectedItem = reservationData.Reservationview.StartLocationName; dropOffLocation.SelectedItem = reservationData.Reservationview.EndLocationName; pickUpTime.Time = DateTime.Parse(reservationData.Reservationview.StartDateStr).TimeOfDay; dropOffTime.Time = DateTime.Parse(reservationData.Reservationview.EndDateStr).TimeOfDay; } }