Ejemplo n.º 1
0
        private async void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ProgressBar.IsIndeterminate = true;
                ProgressBar.Visibility      = Visibility.Visible;
                Book newBook = new Book();
                newBook.BookId = Int32.Parse(TextBoxId.Text);
                newBook.Title  = TextBoxTitle.Text;
                newBook.ISBN   = TextBoxISBN.Text;
                string result = await webService.AddBookAsync(newBook);

                ProgressBar.Visibility      = Visibility.Collapsed;
                ProgressBar.IsIndeterminate = false;
                if (result != null)
                {
                    MessageDialog messageDialog = new MessageDialog("Inserted successfully!");
                    await messageDialog.ShowAsync();

                    Reset();
                }
                else
                {
                    MessageDialog messageDialog = new MessageDialog("Can't Insert!");
                    await messageDialog.ShowAsync();
                }
                getBook();
            }
            catch (Exception ex)
            {
                MessageDialog messageDialog = new MessageDialog(ex.Message);
                await messageDialog.ShowAsync();

                ProgressBar.Visibility      = Visibility.Collapsed;
                ProgressBar.IsIndeterminate = false;
            }
        }