Пример #1
0
        private void ExportChatInviteAsync()
        {
            var channel = _chat as TLChannel;

            if (channel != null)
            {
                IsWorking = true;
                MTProtoService.ExportInviteAsync(channel.ToInputChannel(),
                                                 chatInviteBase => BeginOnUIThread(() =>
                {
                    IsWorking = false;
                    var chatInviteExported = chatInviteBase as TLChatInviteExported;
                    if (chatInviteExported != null)
                    {
                        Link = chatInviteExported.Link.ToString();
                    }
                    else
                    {
                        Link = string.Empty;
                    }

                    _chat.ExportedInvite = chatInviteExported;
                    CacheService.Commit();
                }),
                                                 error => BeginOnUIThread(() =>
                {
                    IsWorking = false;
                }));

                return;
            }

            IsWorking = true;
            MTProtoService.ExportChatInviteAsync(_chat.Id,
                                                 chatInviteBase => BeginOnUIThread(() =>
            {
                IsWorking = false;
                var chatInviteExported = chatInviteBase as TLChatInviteExported;
                if (chatInviteExported != null)
                {
                    Link = chatInviteExported.Link.ToString();
                }
                else
                {
                    Link = string.Empty;
                }

                _chat.ExportedInvite = chatInviteExported;
                CacheService.Commit();
            }),
                                                 error => BeginOnUIThread(() =>
            {
                IsWorking = false;
            }));
        }