Ejemplo n.º 1
0
        async Task ExecuteRefreshCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var _items = await table.GetItemsAsync();

                Items.Clear();
                foreach (var item in _items)
                {
                    Items.Add(item);
                }

                IsBusy = false;
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK");
            }
        }
        public static async Task <IEnumerable <T> > WhereAsync <T>(
            this ITableDataStore <T> store, Func <T, bool> predicate)
            where T : EntityData
        {
            var items = await store.GetItemsAsync().ConfigureAwait(false);

            return(items.Where(predicate));
        }
Ejemplo n.º 3
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            client = new EasyMobileServiceClient();
            client.Initialize("http://xamarin-todo-sample.azurewebsites.net");
            client.RegisterTable<ToDo>();
            client.FinalizeSchema();

            dataStore = client.Table<ToDo>();
            await dataStore.Sync();
            items = await dataStore.GetItemsAsync();
        }
Ejemplo n.º 4
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            client = new EasyMobileServiceClient();
            client.Initialize("http://xamarin-todo-sample.azurewebsites.net");
            client.RegisterTable <ToDo>();
            client.FinalizeSchema();

            dataStore = client.Table <ToDo>();
            await dataStore.Sync();

            items = await dataStore.GetItemsAsync();
        }
Ejemplo n.º 5
0
        private async Task ExecuteRefreshCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            Exception exceptionToDisplay = null;

            try
            {
                var cancellationToken = _cancellationTokenSource.Token;
                var items             = await _table.GetItemsAsync().ConfigureAwait(true);

                if (!cancellationToken.IsCancellationRequested)
                {
                    Items.Clear();
                    foreach (var item in items)
                    {
                        Items.Add(item);
                    }
                }
            }
            catch (OperationCanceledException)
            {
            }
            catch (Exception ex)
            {
                exceptionToDisplay = ex;
            }
            finally
            {
                IsBusy = false;
            }

            if (exceptionToDisplay != null)
            {
                await Application.Current.MainPage.DisplayAlert("Error", exceptionToDisplay.Message, "OK");
            }
        }
Ejemplo n.º 6
0
        async Task GetSpeakers()
        {
            if (IsBusy)
            {
                return;
            }

            Exception error = null;

            try
            {
                IsBusy = true;

                var items = await table.GetItemsAsync();

                Speakers.Clear();
                foreach (var item in items)
                {
                    Speakers.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex);
                error = ex;
            }
            finally
            {
                IsBusy = false;
            }

            if (error != null)
            {
                await Application.Current.MainPage.DisplayAlert("Error!", error.Message, "OK");
            }
        }
Ejemplo n.º 7
0
 public Task <IEnumerable <Coffee> > GetCoffees() => table.GetItemsAsync();
Ejemplo n.º 8
0
 public Task <IEnumerable <Cache> > GetCaches() => cacheTable.GetItemsAsync();