Exemple #1
0
        private async void Edit_Click(object sender,
                                      RoutedEventArgs e)
        {
            EditButton.IsEnabled = false;

            try
            {
                if (!CurrentCommentData.User.Id.HasValue || CurrentCommentData.User.Id == -1)
                {
                    return;
                }
                if (CurrentCommentData.User.Id != SettingsManager.PersistentSettings.CurrentUser.Id)
                {
                    return;
                }

                var title   = LocalizationUtils.GetLocalized("EditingCommentTitle");
                var message = LocalizationUtils.GetLocalized("EditingCommentMessage");

                var oldValue = CurrentCommentData.Text;
                var value    = await DialogManager.ShowMultilineTextDialog(
                    title, message, oldValue)
                               .ConfigureAwait(true);

                if (value == null)
                {
                    return;
                }

                var request = await PostApi.EditComment(
                    SettingsManager.PersistentSettings.CurrentUser.Token,
                    CurrentCommentData.Id,
                    value)
                              .ConfigureAwait(true);

                if (request.IsError)
                {
                    await DialogManager.ShowErrorDialog(request.Message)
                    .ConfigureAwait(true);

                    return;
                }

                CurrentCommentData.Text = value;
            }
            finally
            {
                EditButton.IsEnabled = true;
            }
        }