コード例 #1
0
        async Task ExecuteLoadStopsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Stops = await StopDataStore.ListSubscribe($"routes/{Route.Id}/Stops");

                Stops.ToList().ForEach((stop) =>
                {
                    stop.Object.Id = stop.Key;
                    //stop.Object.PropertyChanged += Stop_PropertyChanged;
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #2
0
        async void Stop_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var stop = sender as FirebaseObject <Stop>;
            await StopDataStore.UpdateAsync(stop, $"routes/{Route.Id}/Stops/{stop.Key}");

            //await RouteDataStore.UpdateAsync(Route);
        }
コード例 #3
0
        public RoutesViewModel()
        {
            Title             = "Browse";
            Routes            = new ObservableCollection <FirebaseObject <Route> >();
            LoadRoutesCommand = new Command(async() => await ExecuteLoadRoutesCommand());

            MessagingCenter.Subscribe <NewRoutePage, Route>(this, "AddRoute", async(obj, route) =>
            {
                var _route        = route as Route;
                var _stops        = _route.Stops as Dictionary <string, Stop>;
                _route.Stops      = null;
                _route.CreatedAt  = DateTime.Now;
                _route.ModifiedAt = DateTime.Now;

                var newRoute = await RouteDataStore.AddAsync(_route);
                _stops.ForEach(async stop => await StopDataStore.AddAsync(stop.Value, $"routes/{newRoute.Key}/Stops"));
            });
        }
コード例 #4
0
 public async void RemoveStop(FirebaseObject <Stop> stop)
 {
     Stops.Remove(stop);
     await StopDataStore.DeleteAsync($"routes/{Route.Id}/Stops/{stop.Key}");
 }
コード例 #5
0
 public async void UpdateStop(FirebaseObject <Stop> stop)
 {
     await StopDataStore.UpdateAsync(stop.Object, $"routes/{Route.Id}/Stops/{stop.Key}");
 }