Example #1
0
        private void EditComment()
        {
            if (string.IsNullOrEmpty(replyEditTextBox.Text))
            {
                if (_messageBoxIsShown)
                {
                    return;
                }
                _messageBoxIsShown = true;
                MessageBox.Show(_localizedStrings.Messages.MissingFields);
                _messageBoxIsShown = false;
                replyEditTextBox.Focus();
                return;
            }

            if (!App.isNetworkAvailable())
            {
                Exception connErr = new NoConnectionException();
                this.HandleException(connErr);
                return;
            }

            Comment comment = DataContext as Comment;

            comment.Content = replyEditTextBox.Text;

            EditCommentRPC rpc = new EditCommentRPC(App.MasterViewModel.CurrentBlog, comment);

            rpc.Completed += OnEditCommentRPCCompleted;
            rpc.ExecuteAsync();
            _currentConnection = rpc;

            ApplicationBar.IsVisible = false;
            App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.EditingComment);
        }
Example #2
0
        private void OnSpamIconButtonClick(object sender, EventArgs e)
        {
            if (!App.isNetworkAvailable())
            {
                Exception connErr = new NoConnectionException();
                this.HandleException(connErr);
                return;
            }
            string           prompt = _localizedStrings.Prompts.ConfirmMarkSpamComment;
            MessageBoxResult result = MessageBox.Show(prompt, _localizedStrings.Prompts.Confirm, MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                Comment comment = DataContext as Comment;
                comment.CommentStatus = eCommentStatus.spam;

                EditCommentRPC rpc = new EditCommentRPC(this._currentBlog, comment);
                rpc.Completed += OnEditCommentRPCCompleted;
                rpc.ExecuteAsync();
                _currentConnection = rpc;

                ApplicationBar.IsVisible = false;
                App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.MarkingAsSpam);
            }
            else
            {
                return;
            }
        }
Example #3
0
        private void OnApproveIconButtonClick(object sender, EventArgs e)
        {
            if (!App.isNetworkAvailable())
            {
                Exception connErr = new NoConnectionException();
                this.HandleException(connErr);
                return;
            }
            Comment comment = DataContext as Comment;

            comment.CommentStatus = eCommentStatus.approve;

            EditCommentRPC rpc = new EditCommentRPC(App.MasterViewModel.CurrentBlog, comment);

            rpc.Completed += OnEditCommentRPCCompleted;
            rpc.ExecuteAsync();
            _currentConnection = rpc;

            ApplicationBar.IsVisible = false;
            App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.ApprovingComment);
        }
Example #4
0
        private void OnEditCommentRPCCompleted(object sender, XMLRPCCompletedEventArgs <Comment> args)
        {
            EditCommentRPC rpc = sender as EditCommentRPC;

            rpc.Completed -= OnEditCommentRPCCompleted;

            if (args.Cancelled)
            {
                return;
            }

            ApplicationBar.IsVisible = true;
            App.WaitIndicationService.HideIndicator();
            if (null == args.Error)
            {
                NavigationService.GoBack();
            }
            else
            {
                this.HandleException(args.Error);
                ChangeApplicationBarAppearance();
            }
        }
        public void ExecuteAsync()
        {
            ValidateValues();

            if (0 == Comments.Count)
            {
                List<Comment> items = new List<Comment>();
                XMLRPCCompletedEventArgs<Comment> args = new XMLRPCCompletedEventArgs<Comment>(items, null, false, null);
                NotifyCompleted(args);
                return;
            }

            _modifiedComments = Comments.Where(comment => CommentStatus != comment.CommentStatus).ToList();

            if (0 == _modifiedComments.Count)
            {
                List<Comment> items = new List<Comment>();
                XMLRPCCompletedEventArgs<Comment> args = new XMLRPCCompletedEventArgs<Comment>(items, null, false, null);
                NotifyCompleted(args);
                return;
            }

            //initialize our counter ivar
            _numberOfCompletedRPCs = 0;

            //initialize our success/failure collections
            if (null != _successes)
            {
                _successes.Clear();
                _successes = null;
            }
            _successes = new List<XMLRPCCompletedEventArgs<Comment>>();

            if (null != _failures)
            {
                _failures.Clear();
                _failures = null;
            }
            _failures = new List<XMLRPCCompletedEventArgs<Comment>>();

            _operation = AsyncOperationManager.CreateOperation(Guid.NewGuid());

            _modifiedComments.ForEach(comment =>
            {
                comment.CommentStatus = this.CommentStatus;

                EditCommentRPC rpc = new EditCommentRPC(DataService.Current.CurrentBlog, comment);
                rpc.Completed += OnEditCommentRPCCompleted;
                rpc.ExecuteAsync();
            });
        }
        private void OnUnapproveIconButtonClick(object sender, EventArgs e)
        {
            if (!App.isNetworkAvailable())
            {
                Exception connErr = new NoConnectionException();
                this.HandleException(connErr);
                return;
            }
            Comment comment = DataContext as Comment;
            comment.CommentStatus = eCommentStatus.hold;

            EditCommentRPC rpc = new EditCommentRPC(App.MasterViewModel.CurrentBlog, comment);
            rpc.Completed += OnEditCommentRPCCompleted;
            rpc.ExecuteAsync();
            _currentConnection = rpc;

            ApplicationBar.IsVisible = false;
            App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UnapprovingComment);
        }
        private void OnSpamIconButtonClick(object sender, EventArgs e)
        {
            if (!App.isNetworkAvailable())
            {
                Exception connErr = new NoConnectionException();
                this.HandleException(connErr);
                return;
            }
            string prompt = _localizedStrings.Prompts.ConfirmMarkSpamComment;
            if (_messageBoxIsShown)
                return;
            _messageBoxIsShown = true;
            MessageBoxResult result = MessageBox.Show(prompt, _localizedStrings.Prompts.Confirm, MessageBoxButton.OKCancel);
            _messageBoxIsShown = false;
            if (result == MessageBoxResult.OK)
            {
                Comment comment = DataContext as Comment;
                comment.CommentStatus = eCommentStatus.spam;

                EditCommentRPC rpc = new EditCommentRPC(App.MasterViewModel.CurrentBlog, comment);
                rpc.Completed += OnEditCommentRPCCompleted;
                rpc.ExecuteAsync();
                _currentConnection = rpc;

                ApplicationBar.IsVisible = false;
                App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.MarkingAsSpam);
            }
            else
            {
                return;
            }
        }
        private void EditComment()
        {
            if (string.IsNullOrEmpty(replyEditTextBox.Text))
            {
                if (_messageBoxIsShown)
                    return;
                _messageBoxIsShown = true;
                MessageBox.Show(_localizedStrings.Messages.MissingFields);
                _messageBoxIsShown = false;
                replyEditTextBox.Focus();
                return;
            }

            if (!App.isNetworkAvailable())
            {
                Exception connErr = new NoConnectionException();
                this.HandleException(connErr);
                return;
            }

            Comment comment = DataContext as Comment;
            comment.Content = replyEditTextBox.Text;

            EditCommentRPC rpc = new EditCommentRPC(App.MasterViewModel.CurrentBlog, comment);
            rpc.Completed += OnEditCommentRPCCompleted;
            rpc.ExecuteAsync();
            _currentConnection = rpc;

            ApplicationBar.IsVisible = false;
            App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.EditingComment);
        }