private void AcceptCommonRequest(ConnectionModel connectionModel) { UserDialogs.Instance.ShowLoading(AppResources.LoadingSendingAcceptRequest); /* Todo validar * var data = new RequestConnectionData(connectionModel.Request.Requester.Id, * connectionModel.Request.Responder.Id, * AppResources.GetPointsEarned(connectionModel.Request.Responder.UserType), * true); */ var data = new RequestConnectionData(connectionModel.Request.RequesterId, connectionModel.Request.ResponderId, AppResources.GetPointsEarned(AppModel.Instance.Users.Find(connectionModel.Request.ResponderId).UserType), true); data.ConnectionRequestId = connectionModel.Request.Id; var requestTask = new RequestConnectionBackgroundTask(data, true, connectionModel.Request.Id); requestTask.ContinueWith((task, result) => { if (result == null) { UserDialogs.Instance.HideLoading(); AppProvider.PopUpFactory.ShowMessage(AppResources.FailedServer, AppResources.Error); } else { var postBadgeTask = new PostBadgeActionBackgroundTask(AppBadgeType.ConnectTo50Users, AppModel.Instance.CurrentUser.User.Id, AppModel.Instance.CurrentUser.BadgeActions); postBadgeTask.ContinueWith((badgeTask, badgeResult) => { string query = QueryBuilder.Instance.GetConnectionRequestByIdKinveyQuery(connectionModel.Request.Id); var getRequestTask = new GetItemByIdBackgroundTask <ConnectRequest>(query, connectionModel.UserModel.Connections); getRequestTask.ContinueWith((getTask, getResult) => { UserDialogs.Instance.HideLoading(); if (getResult != null) { Device.BeginInvokeOnMainThread(() => { if (Device.OS == TargetPlatform.iOS) { UserDialogs.Instance.ShowSuccess(AppResources.SuccessfulAcceptRequestConnection, 1); } connectionModel.ApplyConnectRequest(getResult); UpdateProfileData(AppModel.Instance.CurrentUser); }); } }); _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(getRequestTask); }); _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(postBadgeTask); _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(new PostBadgeActionBackgroundTask(AppBadgeType.ConnectTo50Users, connectionModel.UserModel.User.Id, null)); } }); _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(requestTask); }
public void OnShareExecuted() { if (AppModel.Instance.CurrentUser != null) { var postBadgeTask = new PostBadgeActionBackgroundTask(AppBadgeType.ShareApp, AppModel.Instance.CurrentUser.User.Id, AppModel.Instance.CurrentUser.BadgeActions); postBadgeTask.ContinueWith((badgeTask, badgeResult) => { UpdateProfileData(AppModel.Instance.CurrentUser); }); _backgroundWorkers[AppBackgroundWorkerType.UserPostData].Add(postBadgeTask); } }