예제 #1
0
        public async Task Consume(ConsumeContext <AccountCreated> context)
        {
            //var ser = JsonSerializer.Serialize(context.Message);
            var acc = context.Message.Event.To();

            Console.WriteLine($"Receive created account with {acc.Id.Value.Value} with convId = {context.ConversationId} ");

            var createTran = new CreateTransaction(
                acc.Id,
                new TransactionId(UniqId.New()),
                new TransactionLabel("user2user_source"),
                new CreateAmountCompletedIncome(AmountFactory.New("10.00", CurrencyFactory.New("MXN"))),
                "asdasd"
                );
            await context.Publish(CreateTransactionCommand.From(createTran));

            createTran = new CreateTransaction(
                acc.Id,
                new TransactionId(UniqId.New()),
                new TransactionLabel("user2user_destination"),
                new CreateAmountCompletedIncome(AmountFactory.New("10.00", CurrencyFactory.New("MXN"))),
                "asdasd"
                );
            await context.Publish(CreateTransactionCommand.From(createTran));
        }
예제 #2
0
        public Transaction To()
        {
            var descr = new TransactionDescription();

            foreach (var kv in Description)
            {
                descr.Add(kv.Key, kv.Value);
            }

            var metadata = new TransactionMetadata();

            foreach (var kv in Metadata)
            {
                metadata.Add(kv.Key, kv.Value);
            }

            var am = AmountFactory.New(AmountValue, AmountCurrency);
            ITransactionAmount amount = AmountType switch
            {
                _completedIncome => new AmountIncomeCompleted(am),
                _cancelledOutcome => new AmountOutcomeCancelled(am),
                _processingOutcome => new AmountOutcomeProcessing(am),
                _completedOutcome => new AmountOutcomeCompleted(am),
                _ => throw new InvalidOperationException("Invalid transaction status")
            };

            return(new Transaction(
                       new AccountId(new UniqId(AccountId)),
                       new TransactionId(new UniqId(Id)),
                       new TransactionLabel(Label),
                       amount,
                       metadata,
                       descr,
                       CreatedOn,
                       UpdateOn
                       ));
        }
예제 #3
0
        public CreateTransaction To()
        {
            Console.WriteLine("My Value {0} {1} {2}", CreateAmountValue, CreateAmountCurrency, CreateAmountType);
            var          am           = AmountFactory.New(CreateAmountValue, CreateAmountCurrency);
            CreateAmount createAmount = CreateAmountType switch
            {
                _processingOutcome => new CreateAmountProcessingOutcome(am),
                _completedIncome => new CreateAmountCompletedIncome(am),
                _ => throw new InvalidOperationException("Invalid create transaction status")
            };

            var descr = new TransactionDescription();

            foreach (var kv in Description)
            {
                descr.Add(kv.Key, kv.Value);
            }

            var metadata = new TransactionMetadata();

            foreach (var kv in Metadata)
            {
                metadata.Add(kv.Key, kv.Value);
            }

            return(new CreateTransaction(
                       new AccountId(new UniqId(AccountId)),
                       new TransactionId(new UniqId(Id)),
                       new TransactionLabel(Label),
                       createAmount,
                       Signature,
                       descr,
                       metadata
                       ));
        }
    }