コード例 #1
0
        public override async Task <bool> RemoveAsync(Trip item)
        {
            bool result = false;

            try
            {
                await InitializeStoreAsync();

                var t = ServiceLocator.Instance.Resolve <IAzureClient>()?.Client?.GetSyncTable <TripPoint>();

                var points = item.Points;
                if (points == null || points.Count == 0)
                {
                    points = new List <TripPoint>(await pointStore.GetPointsForTripAsync(item.Id));
                }

                foreach (var point in points)
                {
                    await t.DeleteAsync(point);
                }

                await Table.DeleteAsync(item); //Delete from the local store
                await SyncAsync();             //Send changes to the mobile service

                result = true;
            }
            catch (Exception e)
            {
                Logger.Instance.Track($"Unable to remove item {item.Id}:{e}");
            }

            return(result);
        }
コード例 #2
0
        public override async Task <bool> RemoveAsync(Trip item)
        {
            bool result = false;

            try
            {
                await InitializeStoreAsync().ConfigureAwait(false);

                var t = ServiceLocator.Instance.Resolve <IAzureClient>()?.Client?.GetSyncTable <TripPoint>();

                var points = item.Points;
                if (points == null || points.Count == 0)
                {
                    points = new List <TripPoint>(await pointStore.GetPointsForTripAsync(item.Id));
                }

                foreach (var point in points)
                {
                    await t.DeleteAsync(point).ConfigureAwait(false);
                }


                await PullLatestAsync().ConfigureAwait(false);

                await Table.DeleteAsync(item).ConfigureAwait(false);
                await SyncAsync().ConfigureAwait(false);

                result = true;
            }
            catch (Exception e)
            {
                Logger.Instance.WriteLine($"Unable to remove item {item.Id}:{e}");
            }

            return(result);
        }