Пример #1
0
        private async void showCharacters(int?ClassID)
        {
            CharacterRepository ch = new CharacterRepository();

            try
            {
                List <Character> characters;
                if (ClassID.GetValueOrDefault() > 0)
                {
                    characters = await ch.GetCharactersByClass(ClassID.GetValueOrDefault());
                }
                else
                {
                    characters = await ch.GetCharacters();

                    charactersResult.Text = "Characters";
                }
                characterList.ItemsSource = characters;
                characterList.IsVisible   = true;
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    if (ex.GetBaseException().Message.Contains("connection with the server"))
                    {
                        await DisplayAlert("Error", "No connection with the server. Check that the Web Service is running and available and then click the Refresh button.", "Ok");
                    }
                    else
                    {
                        await DisplayAlert("Error", "If the problem persists, please call your system administrator.", "Ok");
                    }
                }
                else
                {
                    await DisplayAlert("General Error", "If the problem persists, please call your system administrator.", "Ok");
                }
            }
        }