private async Task DeleteMessageExecute() { if (IsBusy) { return; } string tx = null; try { IsBusy = true; if (FromInbox) { tx = await PhantasmaService.RemoveInboxMessage(SelectedMessage.ID); } else { tx = await PhantasmaService.RemoveOutboxMessage(SelectedMessage.ID); } } catch (Exception ex) { if (ex is RpcClientUnknownException || ex is RpcClientTimeoutException) //todo switch error message { AppSettings.ChangeRpcServer(); } await DialogService.ShowAlertAsync(ex.Message, AppResource.Alert_Error); } finally { IsBusy = false; } if (!string.IsNullOrEmpty(tx)) { await _db.DeleteMessage(SelectedMessage.ToStoreMessage()); await DialogService.ShowAlertAsync("Message will be deleted in the next block", "Success"); //todo move to resources await NavigationService.NavigateBackAsync(); } else { await DialogService.ShowAlertAsync(AppResource.Alert_SomethingWrong, AppResource.Alert_Error); } }
private async Task CloseComposeExecute() { if (IsBusy) { return; } try { IsBusy = true; if (!string.IsNullOrEmpty(Message.TextContent) || !string.IsNullOrEmpty(Message.Subject) || !string.IsNullOrEmpty(Message.ToInbox)) { //todo localization const string cancel = "Cancel"; const string saveDraft = "Save Draft"; const string deleteDraft = "Delete Draft"; var options = new[] { saveDraft, deleteDraft }; var choice = await DialogService.SelectActionAsync("Message", "", cancel, options); if (choice.Equals(cancel)) { return; } if (choice.Equals(saveDraft)) { //todo save to drafts if (_draftMessage != null) { _draftMessage.Subject = Message.Subject; _draftMessage.TextContent = Message.TextContent; _draftMessage.ToInbox = Message.ToInbox; _draftMessage.Date = DateTime.UtcNow; await _db.UpdateMessage(_draftMessage); } else { var newDraft = new DraftMessage { ID = Message.ID, Subject = Message.Subject, TextContent = Message.TextContent, ToInbox = Message.ToInbox, Date = DateTime.UtcNow }; await _db.AddMessage(newDraft); } } else { if (_draftMessage != null) { await _db.DeleteMessage(_draftMessage); } } await DraftsVm.RefreshList(); } await NavigationService.PopAllAsync(true); } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { IsBusy = false; } }