public void AddEventToFavourites(EventData eventData)
        {
            if (AppModel.Instance.CurrentUser == null)
            {
                AppProvider.PopUpFactory.ShowMessage(AppResources.LoginFirstMessage, AppResources.Warning);
                return;
            }

            UserDialogs.Instance.ShowLoading(AppResources.LoadingFavouriteActions);
            FavouriteEventData favData = AppModel.Instance.CurrentUser.FavouriteActions.Items.Find(temp => temp.EventId.Equals(eventData.Id));

            if (favData != null)
            {
                string query = QueryBuilder.Instance.GetDeleteFavEventsKinveyQuery(favData.Id);
                var    deleteFavEventTask = new DeleteDataBackgroundTask <FavouriteEventData>(AppModel.Instance.CurrentUser.FavouriteActions, favData, query);
                deleteFavEventTask.ContinueWith((task, result) => UserDialogs.Instance.HideLoading());
                _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(deleteFavEventTask);
            }
            else
            {
                var getIsFavouriteEventTask = new DownloadFavouriteEventsBackgroundTask(eventData.Id, AppModel.Instance.CurrentUser.User.Id,
                                                                                        AppModel.Instance.CurrentUser.FavouriteActions);

                getIsFavouriteEventTask.ContinueWith((resultIsFavTask, isFavResult) =>
                {
                    if (isFavResult.Count > 0)
                    {
                        UserDialogs.Instance.HideLoading();
                        AppProvider.PopUpFactory.ShowMessage(AppResources.AlreadyLikePostMessage, string.Empty);

                        string query           = QueryBuilder.Instance.GetDeleteFavEventsKinveyQuery(favData.Id);
                        var deleteFavEventTask = new DeleteDataBackgroundTask <FavouriteEventData>(AppModel.Instance.CurrentUser.FavouriteActions, favData, query);
                        deleteFavEventTask.ContinueWith((task, result) => UserDialogs.Instance.HideLoading());
                        _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(deleteFavEventTask);
                    }
                    else
                    {
                        var addToFavouriteTask = new PostFavouriteEventBackgroundTask(AppModel.Instance.CurrentUser.User, eventData,
                                                                                      AppModel.Instance.CurrentUser.FavouriteActions);

                        addToFavouriteTask.ContinueWith((task, result) =>
                        {
                            UserDialogs.Instance.HideLoading();
                            if (result == null)
                            {
                                AppProvider.PopUpFactory.ShowMessage(AppResources.FailedServer, AppResources.Error);
                            }
                            else
                            {
                                UserDialogs.Instance.ShowSuccess(AppResources.SuccessfullFavAdd, 1);
                            }
                        });
                        _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(addToFavouriteTask);
                    }
                });
                _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(getIsFavouriteEventTask);
            }
        }
        public void Logout()
        {
            if (AppModel.Instance.CurrentUser.PushNotificationData != null)
            {
                UserDialogs.Instance.ShowLoading(AppResources.LoadingLogoutUser);

                string query = QueryBuilder.Instance.GetDeletePushNotificationsQuery(AppModel.Instance.CurrentUser.PushNotificationData.Id);
                var    unregisterPushNotificationTask = new DeleteDataBackgroundTask <PushNotificationData>(null, AppModel.Instance.CurrentUser.PushNotificationData, query);
                unregisterPushNotificationTask.ContinueWith((task, result) =>
                {
                    UserDialogs.Instance.HideLoading();
                    AppModel.Instance.LogoutUser();

                    ClearBackgroundWorkers();
                });
                _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(unregisterPushNotificationTask);
            }
            else
            {
                AppModel.Instance.LogoutUser();

                ClearBackgroundWorkers();
            }
        }