Example #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(OrderCreated_V2 message)
        {
            Console.WriteLine(
                $"Shipping BC storing: Order: {message.OrderId} User: {message.UserId} Address: {message.AddressId} Shipping Type: {message.ShippingTypeId}");

            var order = new ShippingOrder
            {
                UserId         = message.UserId,
                OrderId        = message.OrderId,
                AddressId      = message.AddressId,
                ShippingTypeId = message.ShippingTypeId
            };

            ShippingDatabase.AddOrderDetails(order);
        }
        public async Task Consume(ConsumeContext <OrderCreated_V2> context)
        {
            var message = context.Message;

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine(
                "\n--->> Shipping BC storing: Order: {0} User: {1} Shipping Type: {2}\n",
                message.OrderId, message.UserId, message.ShippingTypeId, message.AddressId
                );
            Console.ResetColor();

            var order = new ShippingOrderDbModel
            {
                UserId         = message.UserId,
                OrderId        = message.OrderId,
                AddressId      = message.AddressId,
                ShippingTypeId = message.ShippingTypeId
            };

            ShippingDatabase.AddOrderDetails(order);
        }
        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
            {
                //
            }
        }