Ejemplo n.º 1
0
        private async void SubmitButton_Click(object sender,
                                              RoutedEventArgs e)
        {
            SubmitButton.IsEnabled = false;

            SubmitButton.Focus();

            try
            {
                var result = await PostApi.Add(
                    SettingsManager.PersistentSettings.CurrentUser.Token,
                    ViewModel.CurrentPostData)
                             .ConfigureAwait(true);

                if (result.IsError)
                {
                    await DialogManager.ShowErrorDialog(result.Message)
                    .ConfigureAwait(true);
                }
                else
                {
                    var message = LocalizationUtils
                                  .GetLocalized("PostSubmittedMessage");

                    await DialogManager.ShowSuccessDialog(message)
                    .ConfigureAwait(true);

                    ClearText();
                    ClearImage();
                }
            }
            catch (Exception ex)
            {
                await DialogManager.ShowErrorDialog(ex.Message)
                .ConfigureAwait(true);
            }
            finally
            {
                SubmitButton.IsEnabled = true;
            }
        }