Exemple #1
0
        static void Complete()
        {
            try
            {
                Int32 orderId = GetOrderId(false);
                if (orderId == 0)
                {
                    return;
                }

                OrderEntryReference.OrderEntryClient client =
                    new OrderEntryReference.OrderEntryClient();
                List <Item> items = client.OrderComplete(orderId);
                lastOrderId = 0;
                Console.WriteLine("Order {0} Is Completed", orderId);
                if (items != null && items.Count > 0)
                {
                    Console.WriteLine("\nOrdered Items:");
                    foreach (Item i in items)
                    {
                        Console.WriteLine(
                            "ItemId={0}, Quantity={1}, UnitPrice={2}, Total={3}",
                            i.ItemId, i.Quantity, i.UnitPrice, i.TotalPrice);
                    }
                }
            }
            catch (Exception exception)
            {
                lastOrderId = 0;
                Console.WriteLine("Complete Unhandled exception: {0}",
                                  exception.Message);
            }
        }
Exemple #2
0
        static void Add()
        {
            try
            {
                Int32 orderId = GetOrderId(false);
                if (orderId == 0)
                {
                    return;
                }

                Console.WriteLine(
                    "Enter ItemId and Quantity (Ex: 101 1)");
                String input = Console.ReadLine();

                Int32    itemId   = 0;
                Int32    quantity = 0;
                String[] parts    = input.Split(' ');
                if (parts.Length != 2)
                {
                    Console.WriteLine("Incorrect number of arguments entered!");
                    return;
                }
                Int32.TryParse(parts[0], out itemId);
                Int32.TryParse(parts[1], out quantity);
                if (itemId == 0 || quantity == 0)
                {
                    Console.WriteLine("Arguments in incorrect format!");
                    return;
                }

                Item item = new Item
                {
                    ItemId   = itemId,
                    Quantity = quantity
                };

                OrderEntryReference.OrderEntryClient client =
                    new OrderEntryReference.OrderEntryClient();
                client.AddItem(orderId, item);
                Console.WriteLine("Ordered {0} of ItemId {1} for OrderId {2}",
                                  item.Quantity, item.ItemId, orderId);
            }
            catch (Exception exception)
            {
                lastOrderId = 0;
                Console.WriteLine("Add Unhandled exception: {0}",
                                  exception.Message);
            }
        }
Exemple #3
0
        static void Start()
        {
            try
            {
                Int32 orderId = GetOrderId(true);
                if (orderId == 0)
                {
                    return;
                }

                OrderEntryReference.OrderEntryClient client =
                    new OrderEntryReference.OrderEntryClient();
                client.StartOrder(orderId);
                lastOrderId = orderId;
                Console.WriteLine("New order {0} started", orderId);
            }
            catch (Exception exception)
            {
                lastOrderId = 0;
                Console.WriteLine("Start Unhandled exception: {0}",
                                  exception.Message);
            }
        }