Пример #1
0
        public HomeLocationEditorViewModel(
            ISchedulerProvider schedulerProvider,
            INavigationService navigationService,
            IPlacesProvider placesProvider,
            IEmptyAutocompleteResultProvider autocompleteResultProvider,
            ISettingsProvider settingsProvider,
            IGeocodingProvider geocodingProvider) : base(schedulerProvider, placesProvider, geocodingProvider, navigationService)
        {
            _autocompleteResultProvider = autocompleteResultProvider;

            SelectedAutoCompleteResultModelObservable
            .Subscribe(async result =>
            {
                var address = await geocodingProvider.ReverseGeocodingFromPlaceId(result.PlaceId);
                settingsProvider.SetHomeAddress(address);
                navigationService.GoBack();
            });

            this.Changed(() => SelectedSearchResult)
            .Where(r => r is SetLocationOnMapResultModel)
            .Subscribe(result =>
            {
                navigationService.NavigateTo <ChooseHomeAddressOnMapViewModel>();
            });
        }
        public DestinationLocationEditorViewModel(
            ISchedulerProvider schedulerProvider,
            INavigationService navigationService,
            IPlacesProvider placesProvider,
            IGeocodingProvider geocodingProvider,
            IChooseOnMapViewModelFactory chooseOnMapViewModelFactory,
            IEmptyAutocompleteResultProvider autocompleteResultProvider,
            ISelectedDestinationByMapSubscriber destinationByMapSubscriber)
            : base(schedulerProvider, placesProvider, geocodingProvider, navigationService)
        {
            _navigationService           = navigationService;
            _chooseOnMapViewModelFactory = chooseOnMapViewModelFactory;
            _autocompleteResultProvider  = autocompleteResultProvider;

            this.Changed(() => SelectedSearchResult)
            .Where(r => r is SetLocationOnMapResultModel)
            .ObserveOn(schedulerProvider.SynchronizationContextScheduler)
            .Subscribe(NavigateToChooseDestinationOnMapViewModel);

            destinationByMapSubscriber.Publisher.Handler.Subscribe(address =>
            {
                SelectedAddress = address;
                navigationService.GoBack();
            });
        }
Пример #3
0
 public LoadGeo(IDatabase database, ISession session, IGeocodingProvider geocodingProvider, ILog log)
 {
     m_database          = database;
     m_session           = session;
     m_geocodingProvider = geocodingProvider;
     m_log = log;
 }
 public ChooseHomeAddressOnMapViewModel(
     ISettingsProvider settingsProvider,
     INavigationService navigationService,
     ILocationManager locationManager,
     IGeocodingProvider geocodingProvider) : base(navigationService, locationManager, geocodingProvider)
 {
     _settingsProvider = settingsProvider;
 }
Пример #5
0
 public PickupLocationEditorViewModel(
     ISchedulerProvider schedulerProviderer,
     INavigationService navigationService,
     IPlacesProvider placesProvider,
     IGeocodingProvider geocodingProvider,
     IEmptyAutocompleteResultProvider autocompleteResultProvider) : base(schedulerProviderer, placesProvider, geocodingProvider, navigationService)
 {
     _autocompleteResultProvider = autocompleteResultProvider;
 }
 public ChooseDestinationOnMapViewModel(
     ISchedulerProvider schedulerProvider,
     INavigationService navigationService,
     IGeocodingProvider geocodingProvider)
 {
     _schedulerProvider = schedulerProvider;
     _navigationService = navigationService;
     _geocodingProvider = geocodingProvider;
 }
Пример #7
0
 protected ChooseAddressOnMapViewModelBase(
     INavigationService navigationService,
     ILocationManager locationManager,
     IGeocodingProvider geocodingProvider)
 {
     _navigationService = navigationService;
     _locationManager   = locationManager;
     _geocodingProvider = geocodingProvider;
     MyLocationChanged  = locationManager.LocationChanged;
 }
        protected BaseLocationEditorViewModel(
            ISchedulerProvider schedulerProvider,
            IPlacesProvider placesProvider,
            IGeocodingProvider geocodingProvider,
            INavigationService navigationService)
        {
            _navigationService = navigationService;

            this.Changed(() => SearchText)
            .Where(text => !string.IsNullOrEmpty(text))
            .Throttle(TimeSpan.FromMilliseconds(300), schedulerProvider.DefaultScheduler)
            .ObserveOn(schedulerProvider.SynchronizationContextScheduler)
            .Subscribe(async searchText =>
            {
                IsSearching   = true;
                SearchResults = await placesProvider.GetAutoCompleteResponse(searchText);
                IsSearching   = false;
            });

            this.Changed(() => SearchText)
            .Where(string.IsNullOrEmpty)
            .Subscribe(_ => SearchResults = GetEmptyAutocompleteResult());

            var selectedEmptyAutocompleteResultModelObservable = this.Changed(() => SelectedSearchResult)
                                                                 .Where(result => result is EmptyAutocompleteResultModel)
                                                                 .Cast <EmptyAutocompleteResultModel>();

            selectedEmptyAutocompleteResultModelObservable.Where(r => r.Address == null)
            .ObserveOn(schedulerProvider.SynchronizationContextScheduler)
            .Subscribe(selectedResult =>
            {
                switch (selectedResult)
                {
                case HomeResultModel _:
                    _navigationService.NavigateToSearchView <HomeLocationEditorViewModel>(callBack: null);
                    break;

                case WorkResultModel _:
                    _navigationService.NavigateToSearchView <WorkLocationEditorViewModel>(callBack: null);
                    break;
                }
            });

            var selectedEmptyAddress = selectedEmptyAutocompleteResultModelObservable
                                       .Where(r => r.Address != null)
                                       .Select(r => r.Address);

            SelectedAddress = SelectedAutoCompleteResultModelObservable
                              .Select(x => Observable.FromAsync(() => geocodingProvider.ReverseGeocodingFromPlaceId(x.PlaceId)))
                              .Concat()
                              .Merge(selectedEmptyAddress);
        }
Пример #9
0
        public MainViewModel(
            ISchedulerProvider schedulerProvider,
            IGeocodingProvider geocodingProvider,
            ILocationManager locationManager,
            ITripLocationViewModel tripLocationViewModel)
        {
            _schedulerProvider = schedulerProvider;
            _geocodingProvider = geocodingProvider;
            _locationManager   = locationManager;

            TripLocationViewModel = tripLocationViewModel;
            MyLocationChanged     = locationManager.LocationChanged;
        }
        public CosmosDbDataProvider(IConfiguration config, IGeocodingProvider geocodingProvider)
        {
            _geocodingProvider = geocodingProvider;
            var cosmosClient = new CosmosClient(config["EndpointUri"], config["PrimaryKey"], new CosmosClientOptions
            {
                ApplicationName   = "AskForMasks",
                SerializerOptions = new CosmosSerializationOptions
                {
                    PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase
                }
            });

            _requestContainer = cosmosClient.GetContainer(config["DatabaseId"], config["RequestContainerId"]);
            _bragContainer    = cosmosClient.GetContainer(config["DatabaseId"], config["BragContainerId"]);
            _messageContainer = cosmosClient.GetContainer(config["DatabaseId"], config["MessageContainerId"]);
        }
        protected BaseLocationEditorViewModel(
            ISchedulerProvider schedulerProvider,
            IPlacesProvider placesProvider,
            IGeocodingProvider geocodingProvider,
            INavigationService navigationService)
        {
            _geocodingProvider = geocodingProvider;
            _navigationService = navigationService;

            this.Changed(() => SearchText)
            .Where(text => !string.IsNullOrEmpty(text))
            .Throttle(TimeSpan.FromMilliseconds(300), schedulerProvider.DefaultScheduler)
            .ObserveOn(schedulerProvider.SynchronizationContextScheduler)
            .Subscribe(async searchText =>
            {
                IsSearching   = true;
                SearchResults = await placesProvider.GetAutoCompleteResponse(searchText);
                IsSearching   = false;
            });

            this.Changed(() => SearchText)
            .Where(string.IsNullOrEmpty)
            .Subscribe(_ => SearchResults = GetEmptyAutocompleteResult());

            this.Changed(() => SelectedSearchResult)
            .Where(result => result is EmptyAutocompleteResultModel)
            .Cast <EmptyAutocompleteResultModel>()
            .ObserveOn(schedulerProvider.SynchronizationContextScheduler)
            .Subscribe(selectedResult =>
            {
                if (selectedResult.Address == null)
                {
                    NavigateToLocationEditorViewModel(selectedResult);
                }
                else
                {
                    SelectedAddress = selectedResult.Address;
                    _navigationService.GoBack();
                }
            });

            SelectedAutoCompleteResultModelObservable.Subscribe(async result =>
            {
                await SetAutoCompleteResultModel(result.PlaceId);
            });
        }
Пример #12
0
        public MainViewModel(
            ISchedulerProvider schedulerProvider,
            IGeocodingProvider geocodingProvider,
            ILocationManager locationManager,
            INavigationService navigationService,
            ISearchPlaceViewModelFactory searchPlaceViewModelFactory)
        {
            _schedulerProvider = schedulerProvider;
            _geocodingProvider = geocodingProvider;
            _locationManager   = locationManager;

            MyLocationChanged = locationManager.LocationChanged;


            PickupLocationEditorViewModel      = searchPlaceViewModelFactory.GetPickupLocationEditorViewModel();
            DestinationLocationEditorViewModel = searchPlaceViewModelFactory.GetDestinationLocationEditorViewModel();
            _navigationService = navigationService;
        }
        public WorkLocationEditorViewModel(
            ISchedulerProvider schedulerProvider,
            INavigationService navigationService,
            IPlacesProvider placesProvider,
            IEmptyAutocompleteResultProvider autocompleteResultProvider,
            ISettingsProvider settingsProvider,
            IGeocodingProvider geocodingProvider) : base(schedulerProvider, placesProvider, geocodingProvider, navigationService)
        {
            _navigationService          = navigationService;
            _autocompleteResultProvider = autocompleteResultProvider;
            _settingsProvider           = settingsProvider;
            _geocodingProvider          = geocodingProvider;

            this.Changed(() => SelectedSearchResult)
            .Where(r => r is SetLocationOnMapResultModel)
            .Subscribe(result =>
            {
                navigationService.NavigateTo <ChooseWorkAddressOnMapViewModel>();
            });
        }
 public GeocodingController(IGeocodingProvider geocodingApi, ILogger <GeocodingController> logger)
 {
     this.geocodingApi = geocodingApi;
     this.logger       = logger;
 }
Пример #15
0
 public ChooseWorkAddressOnMapViewModel(
     INavigationService navigationService,
     ILocationManager locationManager,
     IGeocodingProvider geocodingProvider) : base(navigationService, locationManager, geocodingProvider)
 {
 }
Пример #16
0
 public DefaultController(IDataProvider dataProvider, IGeocodingProvider geocodingProvider)
 {
     _dataProvider      = dataProvider;
     _geocodingProvider = geocodingProvider;
 }