Ejemplo n.º 1
0
        private static void ConsumerReceived(object sender, BasicDeliverEventArgs args)
        {
            string message = Encoding.UTF8.GetString(args.Body);

            OrderMessage.Order order = JsonConvert.DeserializeObject <OrderMessage.Order>(message);
            SplitMessageAndSend(order);
        }
Ejemplo n.º 2
0
        private static void SplitMessageAndSend(OrderMessage.Order order)
        {
            int messageLength = order.OrderItems.Count();
            int itemSeq       = 0;

            foreach (OrderMessage.OrderItem item in order.OrderItems)
            {
                if (item.ItemType == OrderMessage.Type.BOOK)
                {
                    SendBook(new OrderItem(order.Id, item.Id, item.Quantity, order.Customer.Email, order.Date, itemSeq, messageLength));
                }
                else if (item.ItemType == OrderMessage.Type.ELETRONIC)
                {
                    SendEletronic(new OrderItem(order.Id, item.Id, item.Quantity, order.Customer.Email, order.Date, itemSeq, messageLength));
                }
                itemSeq++;
            }
        }