예제 #1
0
        public void SearchCommandExecute(string SearchedText)
        {
            var Backup      = StopsBackupCollection;
            var tempRecords = Backup.Where(c => c.StopDesc.IndexOf(SearchedText, StringComparison.OrdinalIgnoreCase) >= 0);

            StopsCollection.Clear();
            foreach (var item in tempRecords)
            {
                StopsCollection.Add(item);
            }
            if (StopsCollection.Count == 0)
            {
                foreach (var item in Backup)
                {
                    StopsCollection.Add(item);
                }
            }
        }
예제 #2
0
        public async Task SelectRouteIndexChanged(object sender, EventArgs e)
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;

            var route = (sender as Picker).SelectedItem as Route;

            StopsCollection.Clear();
            await SetSelectedRoute(route);

            foreach (var stop in Stops)
            {
                StopsCollection.Add(stop);
            }

            IsBusy = false;
        }
예제 #3
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                StopsCollection.Clear();
                var stops = await StopDataStore.GetItemsAsync(true);

                foreach (Stop stop in stops)
                {
                    ToSort.Add(stop);
                }
                ToSort.Sort((x, y) => x.StopDesc.CompareTo(y.StopDesc));
                foreach (Stop stop in ToSort)
                {
                    StopsCollection.Add(stop);
                }
                StopsBackupCollection.Clear();
                foreach (Stop item in StopsCollection)
                {
                    StopsBackupCollection.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                await App.Current.MainPage.DisplayAlert("Błąd", "Coś poszło nie tak", "OK");
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #4
0
        async Task ExecuteLoadDirectionsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                StopsCollection.Clear();
                var stops = await StopDataStore.GetItemsAsync(true);

                foreach (Stop stop in stops)
                {
                    StopsCollection.Add(stop);
                }

                StopTimesCollection.Clear();
                StopTimeDataStore.Clear();
                var stopsTime = await StopTimeDataStore.GetItemsAsync(Route.RouteId, Route.i, true);

                foreach (StopTime stopTime in stopsTime)
                {
                    StopTimesCollection.Add(stopTime);
                }

                foreach (Stop stop in StopsCollection)
                {
                    foreach (StopTime stopTime in StopTimesCollection)
                    {
                        if (stop.StopId == stopTime.StopId)
                        {
                            stopTime.StopDesc = stop.StopDesc;
                        }
                    }
                }
                foreach (StopTime stopTime in StopTimesCollection)
                {
                    stopTime.ArrivalTime   = stopTime.ArrivalTime.Replace("1899-12-30T", "");
                    stopTime.DepartureTime = stopTime.DepartureTime.Replace("1899-12-30T", "");
                    stopTime.ArrivalTime   = stopTime.ArrivalTime.Replace("1899-12-31T", "Następnego dnia o:");
                    stopTime.DepartureTime = stopTime.DepartureTime.Replace("1899-12-31T", "Następnego dnia o:");
                }

                TripsCollection.Clear();
                var trips = await TripsDataStore.GetItemsAsync(Route.i, true);

                foreach (Trip trip in trips)
                {
                    TripsCollection.Add(trip);
                }
                DirectionsCollection.Clear();
                Direction DirectionZero = new Direction();
                DirectionZero.variants = new List <Variant>();
                Direction DirectionOne = new Direction();
                DirectionOne.variants = new List <Variant>();
                foreach (Trip trip in TripsCollection)
                {
                    if (Route.RouteId == int.Parse(trip.RouteId))
                    {
                        if (trip.DirectionId == "2")
                        {
                            Variant variantV2 = new Variant();
                            variantV2.stopTimesTest   = new List <StopTime>();
                            DirectionZero.directionId = trip.DirectionId;
                            variantV2.directionId     = int.Parse(trip.DirectionId);
                            variantV2.tripId          = int.Parse(trip.TripId);
                            variantV2.tripHeadsign    = trip.TripHeadsign;
                            foreach (StopTime stopTime in StopTimesCollection)
                            {
                                if (int.Parse(stopTime.RouteId) == Route.RouteId && stopTime.TripId == trip.TripId)
                                {
                                    variantV2.stopTimesTest.Add(stopTime);
                                }
                            }
                            DirectionZero.variants.Add(variantV2);
                        }
                        if (trip.DirectionId == "1")
                        {
                            Variant variantV1 = new Variant();
                            variantV1.stopTimesTest  = new List <StopTime>();
                            DirectionOne.directionId = trip.DirectionId;
                            variantV1.directionId    = int.Parse(trip.DirectionId);
                            variantV1.tripId         = int.Parse(trip.TripId);
                            variantV1.tripHeadsign   = trip.TripHeadsign;
                            foreach (StopTime stopTime in StopTimesCollection)
                            {
                                if (int.Parse(stopTime.RouteId) == Route.RouteId && stopTime.TripId == trip.TripId)
                                {
                                    variantV1.stopTimesTest.Add(stopTime);
                                }
                            }
                            DirectionOne.variants.Add(variantV1);
                        }
                    }
                }
                DirectionsCollection.Add(DirectionOne);
                DirectionsCollection.Add(DirectionZero);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                await App.Current.MainPage.DisplayAlert("Błąd", "Coś poszło nie tak", "OK");
            }
            finally
            {
                IsBusy = false;
            }
        }