private async void CommandCreateAction() { HasActiveTask = true; var segment = _entity.Content.FirstOrDefault(x => x.Type == ContentSegmentType.Text); if (segment != null) segment.Text = segment.Text?.Trim(); try { if (_entity.ID == null) _entity = await _client.CreatePostAsync(_userID, _entity, CancellationToken.None); else _entity = await _client.UpdatePostAsync(_userID, _entity.ID, _entity, CancellationToken.None); NavigationService.GoBack(); } catch (TaskCanceledException) { } catch (Exception ex) { var template = new DialogTemplate { Title = "Something went wrong", Content = $"There is a problem sending your status. Inquiring minds may find this information helpful: {ex.Message}", PrimaryButtonText = "Close" }; await _dialogService.ShowAsync(template); } HasActiveTask = false; }
private async void CommandRemoveAction() { 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) await RemoveCommentAsync(); }
private async Task RemovePostAsync() { HasActiveTask = true; try { await _client.RemovePostAsync(_userID, _entity.ID, CancellationToken.None); var parameters = new Dictionary<string, object> { { NavigationParameters.UserID, _userID } }; NavigationService.Navigate(NavigationRegistry.HomePage, parameters); } catch (TaskCanceledException) { } catch (Exception ex) { var template = new DialogTemplate { Title = "Something went wrong", Content = $"There is a problem removing your status. Inquiring minds may find this information helpful: {ex.Message}", PrimaryButtonText = "Close" }; await _dialogService.ShowAsync(template); } HasActiveTask = false; }
private async Task PopulateDataAsync() { try { HasActiveTask = true; _entity = await _client.FetchPostAsync(_userID, _entity.ID, CancellationToken.None); OnEntityUpdated(); } catch (TaskCanceledException) { } catch (Exception ex) { var template = new DialogTemplate { Title = "Something went wrong", Content = $"There is a problem fetching your status. Inquiring minds may find this information helpful: {ex.Message}", PrimaryButtonText = "Close" }; await _dialogService.ShowAsync(template); } finally { HasActiveTask = false; } }
private async Task RemovePostAsync() { HasActiveTask = true; try { var index = EntriesJournal.IndexOf(_selectedEntryJournal); await _client.RemovePostAsync(_userID, _selectedEntryJournal.ID, CancellationToken.None); EntriesJournal.RemoveAt(index); if (EntriesJournal.Count == 0) SelectedEntryJournal = null; else if (index < EntriesJournal.Count) SelectedEntryJournal = EntriesJournal.ElementAt(index); else if (index == EntriesJournal.Count) SelectedEntryJournal = EntriesJournal.ElementAt(index - 1); } catch (TaskCanceledException) { } catch (Exception ex) { var template = new DialogTemplate { Title = "Something went wrong", Content = $"There is a problem removing your status. Inquiring minds may find this information helpful: {ex.Message}", PrimaryButtonText = "Close" }; await _dialogService.ShowAsync(template); } HasActiveTask = false; }
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; }
private async Task SignUpAsync() { HasActiveTask = true; try { _terminator = new CancellationTokenSource(); var token = new SignUpToken { ID = _tuple.ID, Key = _tuple.Key, Name = _name }; var user = await _client.SignUpAsync(_tuple.Server, token, _terminator.Token); await _storage.StoreDataAsync("signin", new[] { _tuple }); var parameters = new Dictionary<string, object> { { NavigationParameters.UserID, user.ID } }; NavigationService.Navigate(NavigationRegistry.HomePage, parameters); } catch (TaskCanceledException) { } catch (Exception ex) { var template = new DialogTemplate { Title = "Something went wrong", Content = $"There is a problem signing you up. Inquiring minds may find this information helpful: {ex.Message}", PrimaryButtonText = "Close" }; await _dialogService.ShowAsync(template); } finally { _terminator = null; } HasActiveTask = false; }
private async Task RemoveCommentAsync() { HasActiveTask = true; try { await _client.RemovePostCommentAsync(_userID, _postID, _entity.ID, CancellationToken.None); NavigationService.GoBack(); } catch (TaskCanceledException) { } catch (Exception ex) { var template = new DialogTemplate { Title = "Something went wrong", Content = $"There is a problem removing your comment. Inquiring minds may find this information helpful: {ex.Message}", PrimaryButtonText = "Close" }; await _dialogService.ShowAsync(template); } HasActiveTask = false; }