/// need to check this for dispose call
        //public async Task RunPendingActivitiesJob(CancellationToken token)
        //{
        //    await Task.Run(async () =>
        //    {
        //        var pendingActivities = _dbHandler.GetAll();

        //        foreach (var bgActivity in pendingActivities)
        //        {
        //            await CompleteActivity(bgActivity);
        //            Device.BeginInvokeOnMainThread(() =>
        //            {
        //                MessagingCenter.Send<BGActivity>(bgActivity, AppHelper.BACKGROUND_ACTIVITY_MESSAAGE);
        //            });
        //        }
        //    }, token);
        //}

        public async Task <bool> CompleteActivity(BGActivity bgActivity)
        {
            IRestHandler <BGActivity> _restHandler = new RestHandler <BGActivity>(bgActivity.ServiceURL);
            var result = await _restHandler.TriggerPUT(bgActivity.TargetObjectId, bgActivity.TargetObjectJSON);

            if (result)
            {
                DeliveryVM.Instance.RefreshDeliveries();
                using (_dbHandler = SADFactory.GetDBHandler <BGActivity>())
                {
                    _dbHandler.DeleteItem(bgActivity.ActivityId);
                }
            }
            return(result);
        }
        public bool SaveActivity(BGActivity bGActivity)
        {
            int rowsEffected = -1;

            using (_dbHandler = SADFactory.GetDBHandler <BGActivity>())
            {
                var existingActivitys = _dbHandler.GetAll(a => a.TargetObjectId == bGActivity.TargetObjectId);

                if (existingActivitys.Count > 0)
                {
                    var existingActivity = existingActivitys.First();
                    _dbHandler.DeleteItem(existingActivity.ActivityId);
                }
                rowsEffected = _dbHandler.Add(bGActivity);
            }
            return(rowsEffected != -1);
        }