Beispiel #1
0
        public async Task DeleteWalletsAsync(string blockchainType, Guid clientId, string address)
        {
            await _walletRepository.DeleteIfExistsAsync(blockchainType, clientId, address);

            var @event = new WalletArchivedEvent()
            {
                Address        = address,
                BlockchainType = blockchainType,
                ClientId       = clientId
            };

            _cqrsEngine.PublishEvent
            (
                @event,
                BlockchainWalletsBoundedContext.Name
            );
        }
        private async Task Handle(WalletArchivedEvent evt, ICommandSender sender)
        {
            var address        = evt.Address;
            var blockchainType = evt.BlockchainType;

            Task <bool> WalletIsSubscribedAsync(MonitoringSubscriptionType subscriptionType)
            {
                return(_monitoringSubscriptionRepository.WalletIsSubscribedAsync
                       (
                           blockchainType: blockchainType,
                           address: address,
                           subscriptionType: subscriptionType
                       ));
            }

            if (await WalletIsSubscribedAsync(MonitoringSubscriptionType.Balance))
            {
                sender.SendCommand
                (
                    new EndBalanceMonitoringCommand
                {
                    Address        = address,
                    BlockchainType = blockchainType
                },
                    BlockchainWalletsBoundedContext.Name
                );
            }

            if (await WalletIsSubscribedAsync(MonitoringSubscriptionType.TransactionHistory))
            {
                sender.SendCommand
                (
                    new EndTransactionHistoryMonitoringCommand
                {
                    Address        = address,
                    BlockchainType = blockchainType
                },
                    BlockchainWalletsBoundedContext.Name
                );
            }
        }