private void Button_OnClicked(object sender, RoutedEventArgs e)
        {
            string text = string.Format("\r\n\r\nvar result=API.groups.{0}({{group_id:{1}}});;\r\nif (result==1)\r\n{{\r\n    var invitations=API.groups.getInvites({{count:1,\"fields\":\"members_count\"}});\r\n\r\n    var first_invitation_community=null;\r\n    var first_invitation_inviter=null;\r\n\r\n    if (invitations.items.length>0)\r\n    {{\r\n        first_invitation_community=invitations.items[0];\r\n        first_invitation_inviter=API.users.get({{user_ids:first_invitation_community.invited_by,fields:\"sex\"}})[0];\r\n    }}\r\n\r\n    return\r\n    {{\r\n        \"count\":invitations.count,\r\n        \"first_invitation\":\r\n        {{\r\n            \"community\":first_invitation_community,\r\n            \"inviter\":first_invitation_inviter\r\n        }}\r\n    }};\r\n}}\r\nreturn 0;\r\n\r\n", (sender == this.JoinButton) ? "join" : "leave", this._model.community.id);
            CommunityInvitation model = this.Model;
            Action <BackendResult <CommunityInvitations, ResultCode> > callback = delegate(BackendResult <CommunityInvitations, ResultCode> result)
            {
                Execute.ExecuteOnUIThread(delegate
                {
                    if (result.ResultCode == ResultCode.Succeeded)
                    {
                        CommunityInvitations resultData = result.ResultData;
                        model.InvitationHandledAction.Invoke(resultData);
                        CountersManager.Current.Counters.groups = resultData.count;
                        EventAggregator.Current.Publish(new CountersChanged(CountersManager.Current.Counters));
                    }
                    PageBase.SetInProgress(false);
                });
            };

            PageBase.SetInProgress(true);
            string arg_7C_0 = "execute";
            Dictionary <string, string> expr_62 = new Dictionary <string, string>();

            expr_62.Add("code", text);
            VKRequestsDispatcher.DispatchRequestToVK <CommunityInvitations>(arg_7C_0, expr_62, callback, null, false, true, default(CancellationToken?), null);
        }
Beispiel #2
0
        public void UpdateDataView(CommunityInvitations model)
        {
            if (model == null || model.count == 0)
            {
                return;
            }
            this.TitleBlock.Text = (UIStringFormatterHelper.FormatNumberOfSomething(model.count, CommonResources.Communities_InvitationOneFrm, CommonResources.Communities_InvitationTwoFrm, CommonResources.Communities_InvitationFiveFrm, true, null, false));
            ((UIElement)this.ShowAllBlock).Visibility      = (model.count > 1 ? Visibility.Visible : Visibility.Collapsed);
            model.first_invitation.InvitationHandledAction = (Action <CommunityInvitations>)(invitations => ((GroupsListViewModel)base.DataContext).InvitationsViewModel = invitations);
            ContentControl        invitationView        = this.InvitationView;
            CommunityInvitationUC communityInvitationUc = new CommunityInvitationUC();

            communityInvitationUc.Model = model.first_invitation;
            int num = 0;

            communityInvitationUc.NeedBottomSeparatorLine = num != 0;
            invitationView.Content = communityInvitationUc;
        }