コード例 #1
0
        public WhereToViewModel(IAggregateService aggregateService, IBumbleApiService BumbleApiService, IUberService uberService)
            : base(ApplicationPage.WhereTo, aggregateService)
        {
            this.user             = UnitOfWork.UserRepository.GetUser();
            this.BumbleApiService = BumbleApiService;
            this.uberService      = uberService;

            AppCommandMessage.Send(Messages.Enums.AppCommandMessageReason.RemoveBackEntries);

            Messenger.Default.Register <RecentTripMessage>(this, (action) => SetRecentTrip(action));
            Messenger.Default.Register <FavouriteMessage>(this, (action) => SetFavourite(action));
            Messenger.Default.Register <WhereToMessage>(this, (action) => SetWhereTo(action));

            this.LocationSearchBoxModel    = new SearchBoxModel(UnitOfWork, InMemoryApplicationSettingModel, this, SearchType.Location, BumbleApiService, user, NavigationService);
            this.DestinationSearchBoxModel = new SearchBoxModel(UnitOfWork, InMemoryApplicationSettingModel, this, SearchType.Destination, BumbleApiService, user, NavigationService);

            this.LocationSearchBoxModel.Changed    += LocationSearchBoxModel_Changed;
            this.DestinationSearchBoxModel.Changed += LocationSearchBoxModel_Changed;

            this.LocationSearchBoxModel.SetAutoPopulateState();
        }
コード例 #2
0
        private void SetPageState(SplashScreenMessage splashScreenMessage)
        {
            switch (splashScreenMessage.Reason)
            {
            case Messages.Enums.SplashScreenMessageReason.CountrySelected:
                CountrySelection = selectedCountryPersist.Name;

                NavigationService.GoBack();

                DownloadCountryData();
                break;

            case Messages.Enums.SplashScreenMessageReason.FacebookLogin:
            case Messages.Enums.SplashScreenMessageReason.BumbleLogin:
            case Messages.Enums.SplashScreenMessageReason.TwitterLogin:
                base.user = UnitOfWork.UserRepository.GetUser();
                selectedCountryPersist = user.Country;

                DownloadCountryData();
                break;

            case Messages.Enums.SplashScreenMessageReason.ChangeCountry:
                AppCommandMessage.Send(Messages.Enums.AppCommandMessageReason.RemoveBackEntries);

                base.user         = UnitOfWork.UserRepository.GetUser();
                base.user.Country = null;
                UnitOfWork.UserRepository.Update(base.user);
                UnitOfWork.Save();
                resourcesLoaded = false;
                break;

            case Messages.Enums.SplashScreenMessageReason.ResetApp:
                AppCommandMessage.Send(Messages.Enums.AppCommandMessageReason.RemoveBackEntries);

                DatabaseSetup.Seed(UnitOfWork, true);

                resourcesLoaded = false;
                break;
            }
        }
コード例 #3
0
        private void TryNavigateToStartPage()
        {
            // Navigation service can be null on viewmodel load as it hasn't been populated yet.
            if (NavigationService != null)
            {
                Action navigate = () =>
                {
                    user.AppUsageCount += 1;
                    UnitOfWork.UserRepository.Update(user);
                    UnitOfWork.Save();

                    NavigationService.NavigateTo("/Views/WhereTo.xaml?userId=" + user.Token.ToString());

                    AppCommandMessage.Send(Messages.Enums.AppCommandMessageReason.RemoveBackEntries);
                };

                //Keep trying to navgiate every half a second:
                TaskEx.Delay(500).ContinueWith(t =>
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(navigate);
                });
            }
            else
            {
                Action navigate = () =>
                {
                    TryNavigateToStartPage();
                };

                //Keep trying to navgiate every half a second:
                TaskEx.Delay(500).ContinueWith(t =>
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(navigate);
                });
            }
        }