コード例 #1
0
        private async Task RemoveEntryCommentAsync(CommentEntryViewModel entry)
        {
            var template = new DialogTemplate
            {
                Title = "Remove comment?",
                Content = "Comment will be removed permanently",
                PrimaryButtonText = "Remove",
                SecondaryButtonText = "Cancel"
            };

            var result = await _dialogService.ShowAsync(template);

            if (result != ContentDialogResult.Primary)
                return;

            HasActiveTask = true;

            try
            {
                await _client.RemovePostCommentAsync(_userID, entry.PostID, entry.ID, CancellationToken.None);

                var entryPost = default(PostEntryViewModel);

                if (_selectedMenuIndex == 0)
                    entryPost = EntriesPublic.FirstOrDefault(x => x.ID == entry.PostID);
                else if (_selectedMenuIndex == 1)
                    entryPost = EntriesJournal.FirstOrDefault(x => x.ID == entry.PostID);

                entryPost?.EntriesComments.Remove(entry);
            }
            catch (OperationCanceledException)
            {
            }

            HasActiveTask = false;
        }
コード例 #2
0
 private async void CommandRemoveCommentAction(CommentEntryViewModel entry)
 {
     await RemoveEntryCommentAsync(entry);
 }