Exemplo n.º 1
0
        /// <summary>
        /// Construct the trip view, passing in the persistent trip store. Sets up
        /// a command to handle invoking the Add button.
        /// </summary>
        /// <param name="store"></param>
        public TripListViewModel(TripStore store)
        {
            this.store = store;
            Trips      = store.Trips;

            addTripCommand = new RelayCommand(new Action(AddTrip));
        }
Exemplo n.º 2
0
        internal static void ImportTrips()
        {
            string json     = ReadJsonFile("trips");
            var    tripDtos = JsonConvert.DeserializeObject <IEnumerable <TripImportDto> >(json);

            TripStore.AddTrips(tripDtos);
        }
Exemplo n.º 3
0
 public DebugInfoViewModel(TripStore tripStore, PhotoStore photoStore, LocationService locationService) : base("Highlite")
 {
     _tripStore       = tripStore;
     _photoStore      = photoStore;
     _mainViewModel   = MainViewModel.Instance;
     _locationService = locationService;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Construct Trip ViewModel, providing the store to persist trips.
 /// Creates the RelayCommands to be bound to various buttons in the UI.
 /// </summary>
 /// <param name="store">The persistent store</param>
 public TripViewModel(TripStore store)
 {
     trip              = new Trip();
     saveTripCommand   = new RelayCommand(new Action(SaveTrip));
     deleteTripCommand = new RelayCommand(new Action(DeleteTrip));
     this.store        = store;
 }
Exemplo n.º 5
0
        public static void ImportTrip()
        {
            var json     = File.ReadAllText("../../../Resources/trips.json");
            var tripDTOs = JsonConvert.DeserializeObject <ICollection <TripDTO> >(json);

            TripStore.AddTrip(tripDTOs);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Set up all of the known view models, and instantiate the trip repository.
        /// </summary>
        public ViewModelLocator()
        {
            TripStore store = new TripStore();

            InitializeStore(store);
            modelSet.Add("TripListViewModel", new TripListViewModel(store));
            modelSet.Add("TripViewModel", new TripViewModel(store));
        }
Exemplo n.º 7
0
 public ApiTripController(DBConnectionInfo dBConnectionInfo, string apiEndPoint) : base(dBConnectionInfo)
 {
     endPoint       = apiEndPoint;
     tripStore      = new TripStore(endPoint);
     tripPointStore = new TripPointStore(endPoint);
     poiStore       = new PoiStore(endPoint);
     userStore      = new UserStore(endPoint);
 }
 public ApiTripController(DBConnectionInfo dBConnectionInfo, string UserApiEndPoint, string PoiApiEndPoint, string TripsApiEndPoint) : base(dBConnectionInfo)
 {
     userApiEndPoint  = UserApiEndPoint;
     poiApiEndPoint   = PoiApiEndPoint;
     tripsApiEndPoint = TripsApiEndPoint;
     tripStore        = new TripStore(tripsApiEndPoint);
     tripPointStore   = new TripPointStore(tripsApiEndPoint);
     poiStore         = new PoiStore(poiApiEndPoint);
     userStore        = new UserStore(userApiEndPoint);
 }
Exemplo n.º 9
0
        public TripCreationService ConstructorTest(
            TripStore tripStore,
            PhotoStore photoStore,
            LocationService locationService
            )
        {
            TripCreationService target
                = new TripCreationService(tripStore, photoStore, locationService);

            return(target);
            // TODO: add assertions to method TripCreationServiceTest.ConstructorTest(TripStore, PhotoStore, LocationService)
        }
Exemplo n.º 10
0
 public AlbumViewModel(TripStore tripStore, PhotoStore photoStore, HighliteService highliteService, AlbumService albumService,
                       LocationService locationService, DebugInfoViewModel debugInfo) : base("Highlite")
 {
     _tripStore               = tripStore;
     _photoStore              = photoStore;
     _albumService            = albumService;
     _highliteService         = highliteService;
     _locationService         = locationService;
     _debugInfoVModel         = debugInfo;
     _mainViewModel           = MainViewModel.Instance;
     _mainViewModel.OnRemove += _mainViewModel_OnRemove;
     Load();
 }
Exemplo n.º 11
0
        public async Task DropEverythingAsync()
        {
            Settings.Current.UpdateDatabaseId();
            await TripStore.DropTable();

            await PhotoStore.DropTable();

            await UserStore.DropTable();

            await IOTHubStore.DropTable();

            IsInitialized = false;
            await InitializeAsync();
        }
Exemplo n.º 12
0
        public async Task <bool> SyncAllAsync(bool syncUserSpecific)
        {
            if (!IsInitialized)
            {
                await InitializeAsync();
            }

            var taskList = new List <Task <bool> > {
                TripStore.SyncAsync()
            };

            var successes = await Task.WhenAll(taskList).ConfigureAwait(false);

            return(successes.Any(x => !x)); //if any were a failure.
        }
Exemplo n.º 13
0
        public TripCreationServiceTests()
        {
            _googleClient = new GoogleClient();
            _locationRepo = new LocationRepo(TripLineConfig.LocationRepoPath, forceNew: true);
            _placeRepo    = new PlaceRepo(TripLineConfig.PlaceRepoPath);

            _locationService = new LocationService(_googleClient, _locationRepo, _placeRepo);

            _pictureExifReader = new PictureExifInformationReader();
            _localFileFolder   = new LocalFileFolders(_pictureExifReader);
            _photoStore        = new PhotoStore(new PhotoRepo(), _localFileFolder, _locationService);

            _tripSmartBuilder = new TripSmartBuilder(_locationService, _photoStore, new DestinationBuilder(_locationService));
            _tripStore        = new TripStore(_photoStore, _locationService, _tripSmartBuilder, new TripsRepo());
        }
Exemplo n.º 14
0
        public MainViewModel(ContentControl contentControl) : base("Home")
        {
            Initialize();

            if (_contentControl == null)
            {
                _contentControl = contentControl;
            }

            Instance = this;

            _tripCreationService = Navigator.Configuration.IoC.Resolve(typeof(TripCreationService)) as TripCreationService;

            _tripStore       = Navigator.Configuration.IoC.Resolve(typeof(TripStore)) as TripStore;
            _locationService = Navigator.Configuration.IoC.Resolve(typeof(LocationService)) as LocationService;

            UpdateCounters();
        }
        public PartialViewResult RenderMap()
        {
            var teamendpoint = Configuration.GetValue <string>("TRIPS_ROOT_URL");
            //Get trips
            TripStore   t     = new TripStore(_clientFactory, teamendpoint);
            List <Trip> trips = t.GetItemsAsync().Result;
            //Get Last Trip
            var last  = trips.Max(trip => trip.RecordedTimeStamp);
            var tlast = from Trip latest in trips
                        where latest.RecordedTimeStamp == last
                        select latest;
            //Get TripPoints
            TripPointStore   tps        = new TripPointStore(_clientFactory, teamendpoint);
            List <TripPoint> tripPoints = tps.GetItemsAsync(tlast.First()).Result;


            return(PartialView(tripPoints));
        }
Exemplo n.º 16
0
        public PartialViewResult RenderMap()
        {
            var teamendpoint = _envvars.TRIPS_API_ENDPOINT;
            //Get trips
            TripStore   t     = new TripStore(teamendpoint);
            List <Trip> trips = t.GetItemsAsync().Result;
            //Get Last Trip
            var last  = trips.Max(trip => trip.RecordedTimeStamp);
            var tlast = from Trip latest in trips
                        where latest.RecordedTimeStamp == last
                        select latest;
            //Get TripPoints
            TripPointStore   tps        = new TripPointStore(teamendpoint);
            List <TripPoint> tripPoints = tps.GetItemsAsync(tlast.First()).Result;


            return(PartialView(tripPoints));
        }
Exemplo n.º 17
0
        private async void ExecuteSaveTrip(object obj)
        {
            var localStore = AppStore.Instance;
            var trip       = new Trip
            {
                TripId      = Guid.NewGuid(),
                Name        = TripName,
                Description = Description,
                Created     = DateTimeOffset.Now,
                LastEdit    = DateTimeOffset.Now,
                User        = localStore.User,
                UserId      = localStore.User.Id
            };

            // Local update
            localStore.User.Trips.Add(trip);

            // Cloud update
            var result = await TripStore.AddItemAsync(trip);
        }
        public IActionResult Index()
        {
            var teamendpoint = Configuration.GetValue <string>("TRIPS_ROOT_URL");
            var bingMapsKey  = Configuration.GetValue <string>("BING_MAPS_KEY");

            //Get trips
            TripStore   t     = new TripStore(_clientFactory, teamendpoint);
            List <Trip> trips = t.GetItemsAsync().Result;
            //Get Last Trip
            var last  = trips.Max(trip => trip.RecordedTimeStamp);
            var tlast = from Trip latest in trips
                        where latest.RecordedTimeStamp == last
                        select latest;
            //Get TripPoints
            TripPointStore   tps        = new TripPointStore(_clientFactory, teamendpoint);
            List <TripPoint> tripPoints = tps.GetItemsAsync(tlast.First()).Result;

            ViewData["MapKey"] = bingMapsKey;
            return(View(tripPoints));
        }
Exemplo n.º 19
0
        public IActionResult Index()
        {
            var teamendpoint = _envvars.TRIPS_API_ENDPOINT;
            var bingMapsKey  = _envvars.BING_MAPS_KEY;

            //Get trips
            TripStore   t     = new TripStore(teamendpoint);
            List <Trip> trips = t.GetItemsAsync().Result;
            //Get Last Trip
            var last  = trips.Max(trip => trip.RecordedTimeStamp);
            var tlast = from Trip latest in trips
                        where latest.RecordedTimeStamp == last
                        select latest;
            //Get TripPoints
            TripPointStore   tps        = new TripPointStore(teamendpoint);
            List <TripPoint> tripPoints = tps.GetItemsAsync(tlast.First()).Result;

            ViewData["MapKey"] = bingMapsKey;
            return(View(tripPoints));
        }
Exemplo n.º 20
0
        private List <TripPoint> getRandomTripPoints()
        {
            var teamendpoint = _envvars.TRIPS_API_ENDPOINT;

            //Get trips
            TripStore   t     = new TripStore(teamendpoint);
            List <Trip> trips = t.GetItemsAsync().Result;

            if (trips.Count == 0)
            {
                return(new List <TripPoint>());
            }

            //Get Random Trip
            var  r          = new Random();
            Trip randomTrip = trips.ElementAt(r.Next(0, trips.Count()));

            //Get TripPoints
            TripPointStore tps = new TripPointStore(teamendpoint);

            return(tps.GetItemsAsync(randomTrip).Result);
        }
Exemplo n.º 21
0
        public async Task PullTrips()
        {
            if (App.AllDataFetched)
            {
                // Get Trips from Users collection
                Trips.Clear();
                foreach (var trip in AppStore.Instance.User.Trips)
                {
                    Trips.Add(trip);
                }
                return;
            }
            ;
            var store  = AppStore.Instance;
            var userId = store.User.Id;

            var trips = await TripStore.GetItemsByFkAsync(userId);

            if (trips == null)
            {
                return;
            }
            store.User.Trips = new System.Collections.Generic.List <Trip>();
            store.Trips.Clear();
            foreach (var trip in trips)
            {
                var places = await PlaceStore.GetItemsByFkAsync(trip.Id);

                trip.Places = places.ToList();
                store.User.Trips.Add(trip);
                Trips.Add(trip);
            }

            // All data for this User are fetched yet
            App.AllDataFetched = true;
            return;
        }
Exemplo n.º 22
0
        public HighliteTests()
        {
            ServiceBootStrapper.Configure();

            _googleClient      = new GoogleClient();
            _locationRepo      = new LocationRepo(TripLineConfig.LocationRepoPath);
            _placeRepo         = new PlaceRepo(TripLineConfig.PlaceRepoPath);
            _locationService   = new LocationService(_googleClient, _locationRepo, _placeRepo);
            _pictureExifReader = new PictureExifInformationReader();
            _localFileFolder   = new LocalFileFolders(_pictureExifReader);
            _photoStore        = new PhotoStore(new PhotoRepo(forceNew: false), _localFileFolder, _locationService);
            _tripSmartBuilder  = new TripSmartBuilder(_locationService, _photoStore, new DestinationBuilder(_locationService));
            _tripStore         = new TripStore(_photoStore, _locationService, _tripSmartBuilder, new TripsRepo(forceNew: false));
            _highliteService   = new HighliteService(_photoStore, _tripStore, _locationService);

            var tripCreationService = new TripCreationService(_tripStore, _photoStore, _locationService);

            var result = tripCreationService.Build();

            if (result.NumNewTrips > 0)
            {
                tripCreationService.AddAll();
            }
        }
Exemplo n.º 23
0
 private async void InitializeStore(TripStore store)
 {
     await store.LoadTrips();
 }
Exemplo n.º 24
0
 public async Task InitializeAsync()
 {
     await TripStore.InitializeStoreAsync();
 }