コード例 #1
0
        static void Main(string[] args)
        {
            List <PurchaseItem> purchaseItems = new List <PurchaseItem>();

            // adding 5 items to purchase list
            purchaseItems.Add(new PurchaseItem()
            {
                ItemCode = 1, ItemQty = 4
            });
            purchaseItems.Add(new PurchaseItem()
            {
                ItemCode = 2, ItemQty = 1
            });
            purchaseItems.Add(new PurchaseItem()
            {
                ItemCode = 3, ItemQty = 2
            });
            purchaseItems.Add(new PurchaseItem()
            {
                ItemCode = 4, ItemQty = 3
            });
            purchaseItems.Add(new PurchaseItem()
            {
                ItemCode = 5, ItemQty = 5
            });
            purchaseItems.Add(new PurchaseItem()
            {
                ItemCode = 6, ItemQty = 3
            });
            OnlineShoppingFacade onlineShoppingFacade = new OnlineShoppingFacade();

            onlineShoppingFacade.PurchaseOnlineProducts(purchaseItems);
            Console.ReadKey();
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            OrderDetails orderDetails = new OrderDetails("Skullcandy In-ear", 245789854, 10, 1523987451288731, 999, "Air");

            OnlineShoppingFacade shoppingFacade = new OnlineShoppingFacade(new Inventory(), new Payment(), new Address(), new Discount(), new Shipping());

            shoppingFacade.FinalizeOrder(orderDetails);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // Creating the Order/Product details
            OrderDetails orderDetails =
                new OrderDetails("C# Design Pattern Book",
                                 "Simplified book on design patterns in C#", 500, 10,
                                 "Street No 1", "Educational Area", 1212, "4156213754");

            // Using Facade
            OnlineShoppingFacade facade = new OnlineShoppingFacade();

            facade.FinalizeOrder(orderDetails);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            // Creating the Order/Product details
            OrderDetails orderDetails = new OrderDetails("C# Design Pattern Book", "Simplified book on design patterns in C#",
                                                         500, 10, "Street No 1", "Educational Area", 1212, "4156213754");

            // Using Facade
            OnlineShoppingFacade facade = new OnlineShoppingFacade();

            facade.FinalizeOrder(orderDetails);

            #region Client Code without Facade.

            /*
             * // Updating the inventory.
             * IInventory inventory = new InventoryManager();
             * inventory.Update(orderDetails.ProductNo);
             *
             * // Verfying various details for the order such as the shipping address.
             * IOrderVerify orderVerify = new OrderVerificationManager();
             * orderVerify.VerifyShippingAddress(orderDetails.PinCode);
             *
             *
             *
             * // Calculating the final cost after applying various discounts.
             * ICosting costManger = new CostManager();
             * orderDetails.Price = costManger.ApplyDiscounts(orderDetails.Price, orderDetails.DiscountPercent);
             *
             * // Going through various steps if payment gateway like card verification, charging from the card.
             * IPaymentGateway paymentGateWay = new PaymentGatewayManager();
             * paymentGateWay.VerifyCardDetails(orderDetails.CardNo);
             * paymentGateWay.ProcessPayment(orderDetails.CardNo, orderDetails.Price);
             *
             * // Completing the order by providing Logistics.
             * ILogistics logistics = new LogisticsManager();
             * logistics.ShipProduct(orderDetails.ProductName, string.Format("{0}, {1} - {2}.", orderDetails.AddressLine1,
             *  orderDetails.AddressLine2, orderDetails.PinCode));
             */
            #endregion

            Console.ReadKey();
        }
コード例 #5
0
        private static void OnlineShoppingSystem_WithFacade()
        {
            Console.WriteLine("");
            Console.WriteLine("================ Online Shopping With Facade Object ==================");
            Console.WriteLine("");
            // Creating the Order/Product details
            OrderDetails orderDetails = new OrderDetails(
                "C# Design Pattern Book",                               //Product Name
                "Simplified book on design patterns in C#",             //Description
                500,                                                    //Price
                10,                                                     //Discount in %
                "SF-1, Chitrakut Complex",                              //Address Line 1
                "Nr. Pasha Bhai Park, Gotri, Vadodara, Gujarat, India", //Address Line 2
                390007,                                                 // Pincode
                "4156213754"                                            //Card details
                );

            // Using Facade
            OnlineShoppingFacade facade = new OnlineShoppingFacade();

            facade.FinalizeOrder(orderDetails);
        }