Пример #1
0
        public void Send(List <long> userIds, long giftId, int guid, string message, GiftPrivacy privacy, string section = "", Action <BackendResult <VKList <GiftSentResponse>, ResultCode> > callback = null)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            string index1 = "user_ids";
            string str1   = string.Join <long>(",", (IEnumerable <long>)userIds);

            dictionary[index1] = str1;
            string index2 = "gift_id";
            string str2   = giftId.ToString();

            dictionary[index2] = str2;
            string index3 = "guid";
            string str3   = guid.ToString();

            dictionary[index3] = str3;
            string index4 = "privacy";
            string str4   = ((int)privacy).ToString();

            dictionary[index4] = str4;
            string index5 = "no_inapp";
            string str5   = "1";

            dictionary[index5] = str5;
            Dictionary <string, string> parameters = dictionary;

            if (!string.IsNullOrWhiteSpace(message))
            {
                parameters["message"] = message;
            }
            if (!string.IsNullOrWhiteSpace(section))
            {
                parameters["section"] = section;
            }
            VKRequestsDispatcher.DispatchRequestToVK <VKList <GiftSentResponse> >("gifts.send", parameters, callback, null, false, true, new CancellationToken?(), (Action)(() => EventAggregator.Current.Publish(new GiftsPurchaseStepsEvent(GiftPurchaseStepsSource.gift_page, GiftPurchaseStepsAction.purchase_window))));
        }
Пример #2
0
        public void Send()
        {
            if (this._isSending || this._userIds.Count == 0 || this._giftId == 0L)
            {
                return;
            }
            this._isSending = true;
            this.SetInProgress(true, "");
            EventAggregator.Current.Publish((object)new GiftsPurchaseStepsEvent(GiftPurchaseStepsSource.gift_page, GiftPurchaseStepsAction.purchase_click));
            List <long> userIds      = this._userIds;
            long        giftId       = this._giftId;
            string      message      = this.Message;
            GiftPrivacy privacy      = this.AreNameAndTextPublic ? GiftPrivacy.VisibleToAll : GiftPrivacy.VisibleToRecipient;
            string      categoryName = this._categoryName;
            int         randomId     = this._randomId;

            GiftsService.Instance.Send(userIds, giftId, randomId, message, privacy, categoryName, (Action <BackendResult <VKList <GiftSentResponse>, ResultCode> >)(result =>
            {
                this._isSending = false;
                this.SetInProgress(false, "");
                Execute.ExecuteOnUIThread((Action)(() =>
                {
                    ResultCode resultCode = result.ResultCode;
                    if (resultCode == ResultCode.Succeeded)
                    {
                        EventAggregator.Current.Publish((object)new GiftsPurchaseStepsEvent(GiftPurchaseStepsSource.gift_page, GiftPurchaseStepsAction.success));
                        EventAggregator.Current.Publish((object)new GiftSentEvent(giftId, userIds));
                        this.RemoveGiftSendStepsPages();
                        if (this._navigationService.CanGoBack)
                        {
                            Navigator.Current.GoBack();
                        }
                        else
                        {
                            Navigator.Current.NavigateToMainPage();
                        }
                        new DelayedExecutor(1000).AddToDelayedExecution((Action)(() => Execute.ExecuteOnUIThread((Action)(() => new VKClient.Common.UC.GenericInfoUC().ShowAndHideLater(userIds.Count > 1 ? CommonResources.GiftsSent : CommonResources.GiftSent, null)))));
                    }
                    else
                    {
                        VKClient.Common.UC.GenericInfoUC.ShowBasedOnResult(resultCode, "", null);
                    }
                }));
            }));
        }