Beispiel #1
0
        public override async void Execute(ActionExecutionContext context)
        {
            var repository = WaypointsRepositoryFactory.Create();

            await repository.SaveAsync(_waypoints);

            OnCompleted();
        }
        public void Save_CheckIfTheItemsArePersist_ResultTheSameTripCollection()
        {
            WaypointsRepository repository = WaypointsRepositoryFactory.Create();

            Waypoints waypoints = new Waypoints();

            waypoints.Add(CreateWaypoint());

            Task.Run(() => repository.SaveAsync(waypoints)).Wait();

            Waypoints savedWaypoints = null;

            Task.Run(() => savedWaypoints = repository.LoadAsync().Result).Wait();

            Assert.AreEqual(1, savedWaypoints.Count);
            Assert.IsNotNull(savedWaypoints[0].Position);
        }
Beispiel #3
0
        public MainPageViewModel(IUiService uiService, MenuBarViewModel menuBarViewModel)
            : base(uiService)
        {
            AddLocationsPopup = menuBarViewModel;

            IsAddLocationsPopupVisible = false;
            LoadAddLocationsPopupMenuItems();

            DisplayName = "Where Am I";

            WaypointsRepository repository = WaypointsRepositoryFactory.Create();
            Waypoints           waypoints  = new Waypoints();

            waypoints.Add(CreateWaypoint());

            Waypoints savedWaypoints = null;

            Task.Run(() => savedWaypoints = repository.LoadAsync().Result).Wait();

            //TODO: Delete!!!
            if (savedWaypoints.Count == 0)
            {
                savedWaypoints.PopulateWithMockData();
                repository.SaveAsync(savedWaypoints);
            }

            WaypointList = new ObservableCollection <Waypoint>(savedWaypoints.ToArray());
            var location = GetCurrentLocation();

            if (location == null)
            {
                MessageDialog message = new MessageDialog("GPSLocationNotResolved");
                Task.Run(() => message.ShowAsync()).Wait();
            }
            else
            {
                CurrentLocationLatitude  = location.Latitude;
                CurrentLocationLongitude = location.Longitude;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Invoked when a filter is selected using the ComboBox in snapped view state.
        /// </summary>
        /// <param name="sender">The ComboBox instance.</param>
        /// <param name="e">Event data describing how the selected filter was changed.</param>
        void Filter_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Determine what filter was selected
            var selectedFilter = e.AddedItems.FirstOrDefault() as Filter;

            if (selectedFilter != null)
            {
                // Mirror the results into the corresponding Filter object to allow the
                // RadioButton representation used when not snapped to reflect the change
                selectedFilter.Active = true;

                // TODO: Respond to the change in active filter by setting this.DefaultViewModel["Results"]
                //       to a collection of items with bindable Image, Title, Subtitle, and Description properties

                Waypoints waypoints = null;
                Task.Run(() => waypoints = WaypointsRepositoryFactory.Create().LoadAsync().Result).Wait();
                List <Waypoint> foundItems = waypoints.Search(this.DefaultViewModel["QueryText"].ToString());

                // Ensure results are found
                object results = foundItems;

                ICollection resultsCollection = foundItems;
                this.DefaultViewModel.Add("Results", resultsCollection);

                if (this.DefaultViewModel.TryGetValue("Results", out results) &&
                    (resultsCollection = results as ICollection) != null &&
                    resultsCollection.Count != 0)
                {
                    VisualStateManager.GoToState(this, "ResultsFound", true);
                    return;
                }
            }

            // Display informational text when there are no search results.
            VisualStateManager.GoToState(this, "NoResultsFound", true);
        }