Пример #1
0
        async Task ExecuteRefreshingCommand(bool pullFromCloud = false)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var service = new ZumoService();

                if (pullFromCloud)
                {
                    IsRefreshing = true;
                    await service.SyncOfflineCache();

                    IsRefreshing = false;
                }

                var results = await service.GetAllToDoItems();

                Items.Clear();
                foreach (var item in results)
                {
                    Items.Add(item);
                }
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #2
0
        private async Task ExecuteSaveCmd()
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }
                IsBusy = true;

                var svc = new ZumoService();
                if (string.IsNullOrEmpty(Item.Id))
                {
                    await svc.CreateToDo(Item);
                }
                else
                {
                    await svc.UpdateToDo(Item);
                }

                MessagingCenter.Send(this, "refresh_list");
            }
            finally
            {
                IsBusy = false;
                await nav.PopAsync();
            }
        }
Пример #3
0
        protected async override void OnResume()
        {
            // Handle when your app resumes
            if (Settings.HasSyncStarted)
            {
                var zumoService = new ZumoService();

                var hasPending = await zumoService.HasPendingOperations();

                if (hasPending)
                {
                    await zumoService.SyncOfflineCache();
                }
            }
        }
Пример #4
0
        public ToDoListPageViewModel(INavigation nav)
        {
            Title = "To Do Items";

            navigation = nav;

            InitialRefreshList();

            var service = new ZumoService();

            Task.Run(async() =>
            {
                await service.RegisterForPushNotifications();
            });

            MessagingCenter.Subscribe <PushToSync>(this, "ItemsChanged", async(obj) =>
            {
                await ExecuteRefreshingCommand(true);
            });
        }