Пример #1
0
        public void Logout()
        {
            _tvshowtimeApiService.GetCurrentUser().Subscribe(async(userResponse) =>
            {
                await DeleteUserConnectionProfileAsync(userResponse.User.Username);

                // Navigate back to login page
                await DispatcherHelper.ExecuteOnUIThreadAsync(() =>
                {
                    _navigationService.GoBack();
                });
            });
        }
Пример #2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            bool useReactive = true;

            if (useReactive)
            {
                // Authenticate
                _reactiveApiService.Login(_clientId, _clientSecret)
                .Subscribe((result) =>
                {
                    if (result.HasValue && result.Value)
                    {
                        // Try to use the API
                        _reactiveApiService.GetCurrentUser()
                        .Subscribe((userResult) =>
                        {
                            // TODO
                        },
                                   (error) =>
                        {
                            // TODO
                        });

                        _reactiveApiService.GetAgenda()
                        .Subscribe((agendaResult) =>
                        {
                            // TODO
                        },
                                   (error) =>
                        {
                            // TODO
                        });
                    }
                },
                           (error) =>
                {
                    // TODO
                });
            }
            else
            {
                // Authenticate
                bool?isAuthenticated = await _apiService.LoginAsync(_clientId, _clientSecret);

                // Try to use the API
                try
                {
                    var user = await _apiService.GetCurrentUserAsync();

                    var agenda = await _apiService.GetAgendaAsync();
                }
                catch (Exception ex)
                {
                    return;
                }
            }
        }