public void HandleMessage(PlaceOrder message) { if (_pickListService.GetPickLists(message.OrderId) .Any()) { return; } Console.WriteLine("Place order."); Customer customer = _customerService .GetCustomer( message.CustomerName, message.CustomerAddress); List <OrderLine> orderLines = message.Lines .Select(line => new OrderLine { Customer = customer, Product = _productService .GetProduct( line.ProductNumber), Quantity = line.Quantity }) .ToList(); List <PickList> pickLists = _inventoryAllocationService .AllocateInventory( message.OrderId, orderLines); _pickListService.SavePickLists(pickLists); var orderShippedEvent = new OrderShipped { OrderId = message.OrderId, OrderDate = message.OrderDate, CustomerName = message.CustomerName, CustomerAddress = message.CustomerAddress, Shipments = pickLists .Select(p => new Messages.Shipment { ProductNumber = p.Product.ProductNumber, Quantity = p.Quantity, TrackingNumber = "123-45" }) .ToList() }; _subscriptionRegistry.Publish(orderShippedEvent); }