public void DownloadWallPostLikes(DynamicListData <WallPostLike> wallPostLikes, WallPost wallPost, Action onFinish) { var requestTask = new DownloadWallPostLikesBackgroundTask(wallPost, wallPostLikes); requestTask.ContinueWith((task, result) => Device.BeginInvokeOnMainThread(onFinish)); _backgroundWorkers[AppBackgroundWorkerType.DownloadWallPostLikes].Add(requestTask); }
private void LikeWallPostByUser(WallPost post) { UserDialogs.Instance.ShowLoading(AppResources.LoadingSendingLike); string userId = AppModel.Instance.CurrentUser.User.Id; var getIsLikedPostTask = new DownloadWallPostLikesBackgroundTask(post, userId); getIsLikedPostTask.ContinueWith((resultIsLikedTask, isLikedResult) => { if (isLikedResult.Count > 0) { UserDialogs.Instance.HideLoading(); AppProvider.PopUpFactory.ShowMessage(AppResources.AlreadyLikePostMessage, string.Empty); } else { var postLikeTask = new PostWallLikeBackgroundTask(AppModel.Instance.CurrentUser.User, post); postLikeTask.ContinueWith((task, result) => { if (result == null) { UserDialogs.Instance.HideLoading(); AppProvider.PopUpFactory.ShowMessage(AppResources.FailedServer, AppResources.Error); } else { string query = QueryBuilder.Instance.GetWallPostByIdKinveyQuery(post.Id); var getNewWallPostData = new GetItemByIdBackgroundTask <WallPost>(query, AppModel.Instance.WallPosts); getNewWallPostData.ContinueWith((getTask, getResult) => { UserDialogs.Instance.HideLoading(); if (getResult == null) { AppProvider.PopUpFactory.ShowMessage(AppResources.FailedServer, AppResources.Error); } else { UserDialogs.Instance.ShowSuccess(AppResources.SuccessfulPostVote, 1); } }); _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(getNewWallPostData); } }); _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(postLikeTask); } }); _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(getIsLikedPostTask); }