Пример #1
0
        public void NewOrder(int userId, int productId, int cityId)
        {
            IUserSystem      iUserSystem      = new UserSystem("为什么");
            IStorageSystem   iStorageSystem   = new StorageSystem();
            ILogisticsSystem iLogisticsSystem = new LogisticsSystem();
            IOrderSystem     iOrderSystem     = new OrderSystem();

            if (!iUserSystem.CheckUser(userId))
            {
                Console.WriteLine("用户检测失败");
            }
            else if (!iStorageSystem.CheckStorage(productId))
            {
                Console.WriteLine("仓储检测失败");
            }
            else if (!iLogisticsSystem.CheckLogistics(productId, cityId))
            {
                Console.WriteLine("物流检测失败");
                //不能直接去物流增加一个检测失败的数据记录
                //而是通过物流系统的方法去做
            }
            else if (!iOrderSystem.CheckOrder(userId, productId))
            {
                Console.WriteLine("订单检测失败");
            }
            else
            {
                iOrderSystem.NewOrder(userId, productId);
                iLogisticsSystem.NewLogistics(productId, cityId);
            }
        }
Пример #2
0
        /// <summary>
        /// 门面模式通过是单例的
        /// 门面模式不能直接新增一个物流或者仓储检测方法,只能通过调用物流系统或者仓储系统的检测方法,这是门面模式的严格界定
        /// 用于分层
        /// 门面模式就是为了屏蔽上端知道太多细节
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="productId"></param>
        public void NewOrder(int userId, int productId)
        {
            IUserSystem      iUser      = new UserSystem();
            ILogisticsSystem iLogistics = new LogisticsSystem();
            IStorageSystem   iStorage   = new StorageSystem();
            IOrderSystem     iOrder     = new OrderSystem();

            if (!iUser.CheckUser(userId))
            {
                Console.WriteLine("用户检测失败");
            }
            else if (!iStorage.CheckStorage(productId))
            {
                Console.WriteLine("仓储检测失败");
            }
            else if (!iLogistics.CheckLogistics(userId, productId))
            {
                Console.WriteLine("物流检测失败");
            }
            else if (!iOrder.CheckOrder(userId, productId))
            {
                Console.WriteLine("订单检测失败");
            }
            else
            {
                iOrder.NewOrder(userId, productId);
                iLogistics.NewLogistics(userId, productId);
            }
        }