Пример #1
0
        private void OnDeleteSelectedItem(object obj)
        {
            WaypointList.Remove(SelectedWaypointItem);
            var availableWaipoints = new Waypoints();

            availableWaipoints.AddRange(WaypointList);
            Task.Run(() => _repository.SaveAsync(availableWaipoints));
            NotifyOfPropertyChange(() => WaypointList);
        }
        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);
        }
Пример #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;
            }
        }