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); }); }
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")); }); }