Esempio n. 1
0
        public async Task Consume(ConsumeContext <PaymentAccepted> context)
        {
            var message      = context.Message;
            var address      = ShippingDatabase.GetCustomerAddress(message.OrderId);
            var confirmation = ShippingProvider.ArrangeShippingFor(address, message.OrderId);

            if (confirmation.Status == ShippingStatus.Success)
            {
                await context.Publish <Messages.Events.ShippingArranged>(new
                {
                    OrderId = message.OrderId
                });

                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine(
                    "\n--->> Shipping BC arranged shipping for Order: {0}\n",
                    message.OrderId, address
                    );
                Console.ResetColor();
            }
            else
            {
                // .. notify failed shipping instead
            }
        }
        public void Handle(PaymentAccepted message)
        {
            var address      = ShippingDatabase.GetCustomerAddress(message.OrderId);
            var confirmation = ShippingProvider.ArrangeShippingFor(address, message.OrderId);

            if (confirmation.Status == ShippingProvider.ShippingStatus.Success)
            {
                var evnt = new Shipping.Messages.Events.ShippingArranged
                {
                    OrderId = message.OrderId
                };

                Bus.Publish(evnt);

                Console.WriteLine($"Shipping BC arranged shipping for Order: {message.OrderId} to: {address}");
            }
            else
            {
                //
            }
        }