Example #1
0
        public async Task <StartTransactionResponse> StartTransaction(StartTransactionCommand command)
        {
            var totalTransactionTime = _random.Next(
                _parameters.TransactionMinTimeMs,
                _parameters.TransactionMaxTimeMs);

            await Task.Delay(totalTransactionTime);

            if (totalTransactionTime >= _parameters.TransactionTimeoutTimeMs)
            {
                return(new StartTransactionResponse()
                {
                    ErrorMessage = "Transaction timed out",
                });
            }

            /* Not taking in consideration the currency at this point */
            if (_bankRemainingBalance < command.Amount)
            {
                return(new StartTransactionResponse()
                {
                    ErrorMessage = "Not enough balance for this transaction.",
                });
            }

            _bankRemainingBalance -= command.Amount;

            return(new StartTransactionResponse());
        }
Example #2
0
        public Task <CommandHandlingResult> Handle(StartTransactionCommand command, IEventPublisher publisher)
        {
            publisher.PublishEvent(new TransactionStartedtEvent
            {
                TransactionId = command.TransactionId,
                Address       = command.Address,
                NeoAssetId    = command.NeoAssetId,
                GasAssetId    = command.GasAssetId
            });

            _chaosKitty.Meow(command.TransactionId);

            return(Task.FromResult(CommandHandlingResult.Ok()));
        }