public ManagePageViewModel(IUiService uiService) : base(uiService) { DisplayName = "Where Am I"; Waypoints savedWaypoints = null; Task.Run(() => savedWaypoints = _repository.LoadAsync().Result).Wait(); WaypointList = new ObservableCollection <Waypoint>(savedWaypoints.ToArray()); EditSelectedItemCommand = new DelegateCommand(OnEditSelectedItem); DeleteSelectedItemCommand = new DelegateCommand(OnDeleteSelectedItem); }
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); }
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; } }