Esempio n. 1
0
        public async Task SupportsCooperativeCancellation()
        {
            using (CancellationTokenSource cts = new())
            {
                CommandBase command = new CancellationCommand();
                cts.Cancel();

                OperationCanceledException exception = await Assert.ThrowsAsync <OperationCanceledException>(() => command.ExecuteAsync(cts.Token));

                Assert.Equal(cts.Token, exception.CancellationToken);
            }

            using (CancellationTokenSource cts = new())
            {
                CommandBase command = new CancelCommand();
                cts.Cancel();

                Task <CommandResult> task = command.ExecuteAsync(cts.Token);

                TaskCanceledException exception = await Assert.ThrowsAsync <TaskCanceledException>(() => task);

                Assert.Equal(cts.Token, exception.CancellationToken);
                Assert.Same(task, exception.Task);

                Assert.Equal(TaskStatus.Canceled, task.Status);
                Assert.Null(task.Exception);
            }
        }
        private async Task DeletePayment()
        {
            await paymentService.DeletePayment(SelectedPayment).ConfigureAwait(true);

#pragma warning disable 4014
            backupService.EnqueueBackupTask().ConfigureAwait(true);
#pragma warning restore 4014
            await CancelCommand.ExecuteAsync().ConfigureAwait(true);
        }
Esempio n. 3
0
        private async Task DeleteCategoryAsync()
        {
            if (await DialogService.ShowConfirmMessageAsync(Strings.DeleteTitle, Strings.DeleteCategoryConfirmationMessage))
            {
                await mediator.Send(new DeleteCategoryByIdCommand(SelectedCategory.Id));

                logManager.Info("Category with Id {id} deleted.", SelectedCategory.Id);
                await CancelCommand.ExecuteAsync();
            }
        }
Esempio n. 4
0
        protected async Task DeleteAccount()
        {
            await crudServices.DeleteAndSaveAsync <AccountViewModel>(SelectedAccount.Id)
            .ConfigureAwait(true);

            settingsFacade.LastExecutionTimeStampSyncBackup = DateTime.Now;
#pragma warning disable 4014
            backupService.EnqueueBackupTask().ConfigureAwait(true);
#pragma warning restore 4014
            await CancelCommand.ExecuteAsync().ConfigureAwait(true);
        }
Esempio n. 5
0
        private async Task DeleteCategory()
        {
            await crudServices.DeleteAndSaveAsync <AccountViewModel>(SelectedCategory.Id)
            ;

            settingsFacade.LastExecutionTimeStampSyncBackup = DateTime.Now;
#pragma warning disable 4014
            backupService.EnqueueBackupTask();
#pragma warning restore 4014
            await CancelCommand.ExecuteAsync();
        }
Esempio n. 6
0
        protected override async Task SaveCategory()
        {
            await crudServices.UpdateAndSaveAsync(SelectedCategory);

            if (!crudServices.IsValid)
            {
                await dialogService.ShowMessage(Strings.GeneralErrorTitle, crudServices.GetAllErrors());
            }

            await CancelCommand.ExecuteAsync();
        }
        private async Task DeleteCategory()
        {
            if (await DialogService.ShowConfirmMessageAsync(Strings.DeleteTitle, Strings.DeleteCategoryConfirmationMessage))
            {
                await mediator.Send(new DeleteCategoryByIdCommand(SelectedCategory.Id));

                logManager.Info("Category with Id {id} deleted.", SelectedCategory.Id);

                settingsFacade.LastExecutionTimeStampSyncBackup = DateTime.Now;
                backupService.UploadBackupAsync().FireAndForgetSafeAsync();
                await CancelCommand.ExecuteAsync();
            }
        }
Esempio n. 8
0
        protected override async Task SaveAccount()
        {
            await crudServices.UpdateAndSaveAsync(SelectedAccount)
            .ConfigureAwait(true);

            if (!crudServices.IsValid)
            {
                await dialogService.ShowMessage(Strings.GeneralErrorTitle, crudServices.GetAllErrors())
                .ConfigureAwait(true);
            }

            await CancelCommand.ExecuteAsync().ConfigureAwait(true);
        }
Esempio n. 9
0
        private async Task DeleteCategory()
        {
            if (await dialogService.ShowConfirmMessage(Strings.DeleteTitle, Strings.DeleteCategoryConfirmationMessage))
            {
                await crudServices.DeleteAndSaveAsync <Category>(SelectedCategory.Id);

                logManager.Info("Category with Id {id} deleted.", SelectedCategory.Id);

                settingsFacade.LastExecutionTimeStampSyncBackup = DateTime.Now;
                backupService.EnqueueBackupTask().FireAndForgetSafeAsync();
                await CancelCommand.ExecuteAsync();
            }
        }
Esempio n. 10
0
        protected override async Task SaveCategory()
        {
            await mediator.Send(new CreateCategoryCommand(mapper.Map <Category>(SelectedCategory)));

            await CancelCommand.ExecuteAsync();
        }