/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { Messenger.Default.Send<PageTypeEnumMessage>(PageTypeEnumMessage.PriceEstimatesPage); var dataContext = this.DataContext as Viewmodel.PriceEstimatesViewModel; //if(e.Parameter != null) //{ //CoordinatesDetailModel coordinates = e.Parameter as CoordinatesDetailModel; CoordinatesDetailModel coordinates = new CoordinatesDetailModel(); coordinates.SourceLatitude = "12.9766637"; coordinates.SourceLongitude = "77.5712556"; coordinates.DestinationLatitude = "12.8789001"; coordinates.DestinationLongitude = "77.6089869"; coordinates.CityOfCoordinates = "Bangalore"; dataContext.GetCabFareEstimates(coordinates); //} }
public async void RefreshPage() { if (_oauthUberProvider != null) { CoordinatesDetailModel coordinatesDetailModel = new CoordinatesDetailModel(); coordinatesDetailModel.SourceLatitude = _oauthUberService.SourceLatitude; coordinatesDetailModel.SourceLongitude = _oauthUberService.SourceLongitude; coordinatesDetailModel.DestinationLatitude = _oauthUberService.DestinationLatitude; coordinatesDetailModel.DestinationLongitude = _oauthUberService.DestinationLongitude; coordinatesDetailModel.CityOfCoordinates = _oauthRestOfCabsService.CityOfBooking; GetCabFareEstimates(coordinatesDetailModel, true); } }
public async void GetCabFareEstimates(CoordinatesDetailModel coordinates, bool isRefreshRequired = false) { IsInProgress = true; _oauthUberService.SourceLatitude = coordinates.SourceLatitude; _oauthUberService.SourceLongitude = coordinates.SourceLongitude; _oauthUberService.DestinationLatitude = coordinates.DestinationLatitude; _oauthUberService.DestinationLongitude = coordinates.DestinationLongitude; _oauthRestOfCabsService.SourceLatitude = coordinates.SourceLatitude; _oauthRestOfCabsService.SourceLongitude = coordinates.SourceLongitude; _oauthRestOfCabsService.DestinationLatitude = coordinates.DestinationLatitude; _oauthRestOfCabsService.DestinationLongitude = coordinates.DestinationLongitude; _oauthRestOfCabsService.CityOfBooking = coordinates.CityOfCoordinates; _oauthUberProviderList = await _oauthUberProvider.GetFareEstimates(_oauthUberService); _oauthRestOfCabsProviderResult = await _oauthRestOfCabsProvider.GetFareEstimates(_oauthRestOfCabsService); if (_oauthUberProviderList != null || _oauthRestOfCabsProviderResult != null) { CabsListGroup = new ObservableCollection<CabsListDetailModel>(); foreach (var uberProvider in _oauthUberProviderList) { if (String.IsNullOrWhiteSpace(Distance)) { Distance = String.Format(uberProvider.Distance + " " + Constants.Miles); } CabsListGroup.Add(new CabsListDetailModel(CommonImageSource.GetCabTypeIcon(CabType.uber), uberProvider.DisplayName, uberProvider.CurrencyCode, uberProvider.LowPriceEstimate, uberProvider.HighPriceEstimate, (Convert.ToInt32(uberProvider.TimeEstimate) / 60).ToString(), Convert.ToInt32(uberProvider.HighPriceEstimate), CabType.uber)); } foreach (var cabsProvider in _oauthRestOfCabsProviderResult) { if (cabsProvider.cabServiceProvider.ToLower() != CabType.uber.ToString()) { string priceString; CabType cabType; Enum.TryParse<CabType>(cabsProvider.cabServiceProvider.Replace(" ", "").ToLower(), out cabType); if (cabsProvider.PriceEstimate == Constants.OutOfRangePrice) { priceString = ResourceContentLoader.GetString("NotAvailable"); } else { priceString = cabsProvider.PriceEstimate; } CabsListGroup.Add(new CabsListDetailModel(CommonImageSource.GetCabTypeIcon(cabType), cabsProvider.DisplayName, "INR", priceString, "", cabsProvider.TimeEstimate, Convert.ToInt32(cabsProvider.PriceEstimate), cabType)); } } } else { Messenger.Default.Send<NavigateToPageMessage>(new NavigateToPageMessage()); return; } if (isRefreshRequired) { await Task.Delay(1000); } if (isRefreshRequired) { if (sortCabType != null) { if (sortCabType == SortCabType.Price) CabsListGroup = new ObservableCollection<CabsListDetailModel>(CabsListGroup.OrderBy(x => x.HighPriceEstimateInteger).ToList()); else if (sortCabType == SortCabType.ETA) CabsListGroup = new ObservableCollection<CabsListDetailModel>(CabsListGroup.OrderBy(x => x.EstimatedTimeInteger).ToList()); } } else { CabsListGroup = new ObservableCollection<CabsListDetailModel>(CabsListGroup.OrderBy(x => x.HighPriceEstimateInteger).ToList()); } IsInProgress = false; }