public void PublishCustomerStatusChangedMessage(int customerId, decimal totalPrice, string topic)
        {
            var message = new CustomerStatusChangedMessage
            {
                CustomerId = customerId,
                TotalPrice = totalPrice
            };

            bus.PubSub.Publish(message, topic);
        }
        private void HandleOrderPaid(CustomerStatusChangedMessage message)
        {
            // A service scope is created to get an instance of the product repository.
            // When the service scope is disposed, the product repository instance will
            // also be disposed.
            using (var scope = provider.CreateScope())
            {
                var services     = scope.ServiceProvider;
                var customerRepo = services.GetService <ICustomerRepo>();
                var cust         = customerRepo.ReadById(message.CustomerId);

                cust.CreditStanding = cust.CreditStanding - message.TotalPrice;
                customerRepo.EditCustomer(cust);
            }
        }