public SqliteGtfsLoaderService( IGtfsGenericRepository <Agency> agencyRepository, IGtfsGenericRepository <Calendar> calendarRepository, IGtfsGenericRepository <CalendarDate> calendarDateRepository, IGtfsGenericRepository <FeedInfo> feedInfoRepository, IGtfsGenericRepository <Frequency> frequencyRepository, IGtfsGenericRepository <Route> routeRepository, IGtfsGenericRepository <Shape> shapeRepository, IGtfsGenericRepository <Stop> stopRepository, IGtfsGenericRepository <StopTime> stopTimeRepository, IGtfsGenericRepository <Trip> tripRepository) { _agencyRepository = agencyRepository; _calendarRepository = calendarRepository; _calendarDateRepository = calendarDateRepository; _feedInfoRepository = feedInfoRepository; _frequencyRepository = frequencyRepository; _routeRepository = routeRepository; _shapeRepository = shapeRepository; _stopRepository = stopRepository; _stopTimeRepository = stopTimeRepository; _tripRepository = tripRepository; _loadGtfsDataChannel = Channel.CreateUnbounded <string>(); }
public StopSearchTabViewModel( INavigationService navigationService, IGtfsGenericRepository <Stop> stopRepository) : base(navigationService) { ItemTapped = new DelegateCommand <object>(async args => await ItemTappedEvent(args)); var searchStopCommand = ReactiveCommand.Create <string>(async s => { Stops = new List <StopModel>(); if (string.IsNullOrEmpty(s)) { TotalResultsMessage = string.Empty; IsVisibleStopsListView = false; return; } var tempStops = new List <StopModel>(); var results = stopRepository .Find(x => x.StopId.StartsWith(s)); foreach (var stop in await results) { var stopId = stop.StopId; var stopTitles = stop.StopName.Split("/", 2); var stopTitle = stopTitles[0].Replace($"{stopId}-", "").Trim(); var stopSubtitle = (stopTitles.Length < 2 ? string.Empty : stopTitles[1].Trim()); tempStops.Add(new StopModel(stopId, stopTitle, stopSubtitle)); } Stops = tempStops; TotalResultsMessage = $"Found {Stops.Count()} results."; IsVisibleStopsListView = true; }); this.WhenAnyValue(x => x.EntryStopCode) .Throttle(TimeSpan.FromSeconds(0.8), RxApp.TaskpoolScheduler) .ObserveOn(RxApp.MainThreadScheduler) .InvokeCommand(searchStopCommand); }