Exemplo n.º 1
0
        public Task Handle(BillingRecordCreated message, IMessageHandlerContext context)
        {
            Log.Info($"Received {nameof(BillingRecordCreated)} event/message");
            Data.BillingRecordCreated = true;

            // return Task.CompletedTask;
            return(ProcessOrder(context));
        }
Exemplo n.º 2
0
        // EVENT handler, not COMMAND handler - implementation-wise there's no difference.
        public async Task Handle(OrderCreated message, IMessageHandlerContext context)
        {
            Log.Info($"Received {nameof(OrderCreated)}, OrderId = {message.OrderId} - preparing for billing activities.");

            try
            {
                var billingRecord = new BillingRecordCreated
                {
                    BillingRecordId = Guid.NewGuid().ToString(),
                    OrderId         = message.OrderId,
                    CreatedOn       = message.CreatedOn,
                    CreatedBy       = message.CreatedBy
                };

                await context.Publish(billingRecord);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }