Beispiel #1
0
        private void PlaceDeliveryForOrder(Order pOrder, Delivery pDelivery)
        {
            Delivery  lDelivery  = pDelivery;
            OrderInfo lOrderInfo = new OrderInfo();

            foreach (OrderItem oi in pOrder.OrderItems)
            {
                String        lBookTitle  = oi.Book.Title;
                List <String> lWarehouses = new List <String>();

                foreach (OrderStock os in oi.OrderStocks)
                {
                    lWarehouses.Add(os.Stock.Warehouse.Name);
                }
                lOrderInfo.AddOrderItem(lBookTitle, lWarehouses);
            }

            DeliveryInfo lDeliveryInfo = new DeliveryInfo()
            {
                OrderNumber                 = lDelivery.Order.OrderNumber.ToString(),
                SourceAddress               = lDelivery.SourceAddress,
                DestinationAddress          = lDelivery.DestinationAddress,
                DeliveryNotificationAddress = "net.tcp://localhost:9010/DeliveryNotificationService"
            };

            Console.WriteLine("============Delivery Placed============");
            Console.WriteLine("SUBMITTING DELIVERY SERVICE with the");
            Console.WriteLine("following information:");
            Console.WriteLine("Order Number: " + lDelivery.Order.OrderDate.ToString());
            Console.WriteLine("Source Addr: " + lDelivery.SourceAddress);
            Console.WriteLine("Dest Addr: " + lDelivery.DestinationAddress);
            Console.WriteLine("Time: " + DateTime.Now);
            Console.WriteLine("=======================================");
            Console.WriteLine(" ");
            Guid lDeliveryIdentifier = ExternalServiceFactory.Instance.DeliveryService.SubmitDelivery(lDeliveryInfo, lOrderInfo);

            lDelivery.ExternalDeliveryIdentifier = lDeliveryIdentifier;
            pOrder.Delivery = lDelivery;
        }