コード例 #1
0
ファイル: Form1.cs プロジェクト: borjavelez/B2BRetailer
        private void button1_Click(object sender, EventArgs e)
        {
            Customer customer = new Customer();

            gateway = new SynchronousMessagingGateway(customer);
            int input = 0;

            try
            {
                input = Int32.Parse(textBox1.Text);
                if (input >= 1 && input <= 4)
                {
                    label7.Visible = false;
                    String country   = comboBox1.Text;
                    int    productId = Int32.Parse(textBox1.Text);
                    Order  order     = gateway.send(productId, country, customer);
                    label3.Text    = "From warehouse: " + order.Warehouse;
                    label4.Text    = "Delivery days: " + order.DeliveryDays;
                    label5.Text    = "Shipping cost: " + order.ShippingCost + "€";
                    label6.Text    = "Total cost: " + order.TotalCost.ToString() + "€";
                    label3.Visible = true;
                    label4.Visible = true;
                    label5.Visible = true;
                    label6.Visible = true;
                    //gateway.deleteQueues();
                }
                else
                {
                    throw new Exception();
                }
            } catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
                label7.Visible = true;
                label7.Text    = "Error! \nThe product ID must be a number between 1 and 4";
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            customerID = Guid.NewGuid().ToString("N");

            while (true)
            {
                Console.WriteLine("Welcom to B2B Retailer!\n" + "Please choose from the following menu points:");
                Console.WriteLine("1. Order\n" + "2. Exit");
                var answer = Console.ReadLine();
                switch (Convert.ToInt32(answer))
                {
                case 1:
                    Console.WriteLine("Please Select item you wish to purchase!\n" + "1. Phone \n2. BlackBoard\n3. Watch");
                    var itemID   = Console.ReadLine();
                    var itemName = "";
                    if (itemID == "1")
                    {
                        itemName = "Phone";
                    }

                    else if (itemID == "2")
                    {
                        itemName = "BlackBoard";
                    }

                    else if (itemID == "3")
                    {
                        itemName = "Watch";
                    }
                    else
                    {
                        itemName = itemID;
                    }

                    Console.WriteLine("Please fill out the following info on the order!(Example: Denmark)\n" + "Country >> ");
                    var countryName = Console.ReadLine();
                    var order       = new Order()
                    {
                        Item = new Item()
                        {
                            Name = itemName
                        }, Location = new Location()
                        {
                            CountryName = countryName
                        }, CustomerID = customerID
                    };
                    var gateway = new SynchronousMessagingGateway();
                    //handle response here
                    var itemAtWarehouse = gateway.PurchaseOrder(order);
                    if (itemAtWarehouse.ItemAvailable == false)
                    {
                        Console.WriteLine("Item Not available");
                        Thread.Sleep(1000);
                        goto case 1;
                    }
                    else
                    {
                        Console.WriteLine("Your item shipping cost:" + itemAtWarehouse.Charge);
                        Console.WriteLine("Time to ship Your item: " + itemAtWarehouse.ShippingTime);
                        Console.WriteLine("Are you satisfied with your order? Y/N");
                        var ans = Console.ReadLine();
                        if (ans == "N")
                        {
                            Thread.Sleep(1000);
                            goto case 1;
                        }
                        else
                        {
                            Console.WriteLine("Thank you for your order.");
                            Thread.Sleep(1000);
                        }

                        break;
                    }

                case 2:
                    Console.WriteLine("Thank you for using our application.");
                    Thread.Sleep(3000);
                    Environment.Exit(0);
                    break;
                }
            }
        }
コード例 #3
0
 public Customer(int customerID, int productID)
 {
     this.customerID = customerID;
     this.productID  = productID;
     gateway         = new SynchronousMessagingGateway(customerID);
 }