Пример #1
0
        async Task ExecuteLoadRoutesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Routes.Clear();
                var routes = await RouteDataStore.ListAsync(true);

                foreach (var route in routes)
                {
                    Routes.Add(route);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #2
0
        private async void LoadData(string id)
        {
            Route = await RouteDataStore.GetAsync(id);

            this.Route.Stops.ForEach((stop) => stop.Value.PropertyChanged += Stop_PropertyChanged);
            Title = Route?.Name;
        }
Пример #3
0
        public RoutesViewModel()
        {
            Title             = "Browse";
            Routes            = new ObservableCollection <Route>();
            LoadRoutesCommand = new Command(async() => await ExecuteLoadRoutesCommand());

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

                Routes.Add(_route);
                await RouteDataStore.AddAsync(_route);
            });
        }
Пример #4
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"));
            });
        }
Пример #5
0
        async Task ExecuteLoadRoutesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Routes = await RouteDataStore.ListSubscribe();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #6
0
 public async void UpdateRoute(FirebaseObject <Route> route)
 {
     await RouteDataStore.UpdateAsync(route.Object, $"routes/{route.Object.Id}");
 }
Пример #7
0
 public async void UpdateRoute()
 {
     await RouteDataStore.UpdateAsync(Route, $"routes/{Route.Id}");
 }
Пример #8
0
 public async Task Remove(FirebaseObject <Route> route)
 {
     Routes.Remove(route);
     await RouteDataStore.DeleteAsync($"routes/{route.Key}");
 }