protected override void PageLoaded()
        {
            base.PageLoaded();

            Action fetchMap = async() =>
            {
                if (user != null)
                {
                    UberTrip uberTrip = UnitOfWork.UberTripRepository.GetAll().FirstOrDefault();

                    if (uberTrip != null)
                    {
                        UberMap uberMap = await uberService.GetUberMap(CancellationToken.None, user.UberInfo.AccessToken, uberTrip.RequestId);

                        if (uberMap != null)
                        {
                            UberMapHref = uberMap.Href.ToString();
                        }
                        else
                        {
                        }
                    }
                }

                HideHeaderLoader();
            };

            DispatcherHelper.CheckBeginInvokeOnUI(fetchMap);
        }
Beispiel #2
0
        private void ContinuePreviousTrip()
        {
            if (ContrinuePreviousTripImageOption == "/Images/64/W/TripKarmaWhite.png")
            {
                // Check if we must load last trip from the database first.
                if (!SimpleIoc.Default.ContainsCreated <PathResultsModel>())
                {
                    IEnumerable <Path> paths = UnitOfWork.PathRepository.GetAllCached(UnitOfWork.PublicTransportOperatorRepository.GetAll());

                    List <PathOption> pathOptions = paths.Select(x => x.PathOption).ToList();

                    Path firstPath = paths.First();

                    IEnumerable <TransportMode> modes = UnitOfWork.TransportModeRepository.GetAll();
                    // Attempt to add an uber option.
                    if (modes.Where(x => x.IsEnabled).Select(x => x.ApplicationTransportMode).Contains(ApplicationTransportMode.Taxi) &&
                        base.InMemoryApplicationSettingModel.GetSetting(ApplicationSetting.UseUber).Value &&
                        !UnitOfWork.UberTripRepository.ExistsCached())
                    {
                        double maxDurationInMinutes = (pathOptions.Where(x => !x.IsUber).SelectMany(x => x.Stages).Max(x => x.EndTime) - DateTime.Now).TotalMinutes;
                        pathOptions.Add(new PathOption(pathOptions.Count(), uberService, firstPath.Location, firstPath.Destination, maxDurationInMinutes, user.UberInfo.AccessToken));
                    }

                    PathResultsModel results = new PathResultsModel(new Address(firstPath.LocationText, firstPath.LocationText, firstPath.Location), new Address(firstPath.DestinationText, firstPath.DestinationText, firstPath.Destination), pathOptions, BumbleApiService, user);

                    if (SimpleIoc.Default.IsRegistered <PathResultsModel>())
                    {
                        SimpleIoc.Default.Unregister <PathResultsModel>();
                    }

                    SimpleIoc.Default.Register <PathResultsModel>(() =>
                    {
                        return(results);
                    });

                    if (SimpleIoc.Default.IsRegistered <TripResultsModel>())
                    {
                        SimpleIoc.Default.Unregister <TripResultsModel>();
                    }

                    SimpleIoc.Default.Register <TripResultsModel>(() =>
                    {
                        return(new TripResultsModel());
                    });
                }

                if (base.InMemoryApplicationSettingModel.GetSetting(ApplicationSetting.SkipTripSelection).Value)
                {
                    this.NavigationService.NavigateTo("/Views/TripDetails.xaml");
                }
                else
                {
                    this.NavigationService.NavigateTo("/Views/TripSelection.xaml");
                }
            }
            else
            {
                // Check if uber trip isn't already in memory
                if (!SimpleIoc.Default.ContainsCreated <UberTrip>())
                {
                    UberTrip uberTrip = UnitOfWork.UberTripRepository.GetAll().FirstOrDefault();

                    if (uberTrip != null)
                    {
                        if (SimpleIoc.Default.IsRegistered <UberTrip>())
                        {
                            SimpleIoc.Default.Unregister <UberTrip>();
                        }

                        SimpleIoc.Default.Register <UberTrip>(() =>
                        {
                            return(uberTrip);
                        });

                        this.NavigationService.NavigateTo("/Views/UberTripDetails.xaml");
                    }
                }
                else
                {
                    this.NavigationService.NavigateTo("/Views/UberTripDetails.xaml");
                }
            }
        }