示例#1
0
        private void WireCommands()
        {
            ChooseProfilePageLoaded = new RelayCommand(async() =>
            {
                if (_navigationService.IsNetworkAvailable)
                {
                    SetProgressBar(AppResources.SysTrayGettingProfiles);

                    Log.Info("Getting profiles");

                    try
                    {
                        var profiles = await _apiClient.GetPublicUsersAsync(new CancellationToken());
                        Profiles     = new ObservableCollection <UserDto>();

                        foreach (var profile in profiles)
                        {
                            Profiles.Add(profile);
                        }

                        if (!Profiles.Any())
                        {
                            _navigationService.NavigateTo(Constants.Pages.ManualUsernameView);
                        }
                    }
                    catch (HttpException ex)
                    {
                        Utils.HandleHttpException(ex, "GettingProfiles()", _navigationService, Log);
                    }

                    SetProgressBar();
                }
            });

            LoginCommand = new RelayCommand <object[]>(async loginDetails =>
            {
                var selectedUser = loginDetails[0] as string;
                var pinCode      = loginDetails[1] as string;

                await DoLogin(selectedUser, pinCode);
            });

            ManualLoginCommand = new RelayCommand(async() =>
            {
                await DoLogin(Username, Password);
            });
        }