Esempio n. 1
0
        public Task Handle(PaymentHistoryNegativeEvent message, IMessageHandlerContext context)
        {
            //TODO: actual business logic goes here

            log.Info($"Payment history is negative for CartId {message.CartId}");
            MarkAsComplete();
            return(Task.CompletedTask);
        }
Esempio n. 2
0
        public Task Handle(CheckCustomerPaymentHistoryCommand message, IMessageHandlerContext context)
        {
            //TODO: acutal business logic goes here
            var random = new Random();

            //randomly return negative events
            if (random.Next(0, 5) == 0)
            {
                var paymentHistoryNegative = new PaymentHistoryNegativeEvent
                {
                    CartId = message.CartId
                };
                return(context.Publish(paymentHistoryNegative));
            }

            var paymentHistoryPositive = new PaymentHistoryPositiveEvent
            {
                CartId = message.CartId
            };

            return(context.Publish(paymentHistoryPositive));
        }