示例#1
0
        public static string Encrypt(Order order)
        {
            StringWriter writer = new StringWriter();
            XmlSerializer serializer = new XmlSerializer(typeof(Order));
            Order orderToDecrypt = order;
            using (writer)
            {
                serializer.Serialize(writer, order);

            }
            string nonEncryptedOrder = writer.ToString();
            string encryptedOrder =encryptString(nonEncryptedOrder, KEY);
            return encryptedOrder;
        }
示例#2
0
        public void hotelPriceHasBeenCut(int supplierID, int newPrice){

            //calculate the number of rooms to buy for a given price.
            int desiredNumRoomsToBuy = calculateNumRoomsToBuy(newPrice);



            //create an order object for the purchase
            //Order newOrder = new Order(agencyID, supplierID, desiredNumRoomsToBuy, newPrice, creditCardNumber);

            //just for testing purposes
            if (desiredNumRoomsToBuy != 0)
            {
                Order newOrder = new Order(this.agencyID, supplierID, desiredNumRoomsToBuy, newPrice, getCreditCardNumber());


                //place the new order
                placeOrder(newOrder);
            }
                
            
        }
示例#3
0
        //verifies the validity of an order by checking with the bank.
        private Boolean validateOrder(Order orderToValidate)
        {
            //check with the bank object to see if the credit card is registered
            return Bank.validateCreditCard(orderToValidate.CreditCardNumber);


        }
示例#4
0
 //this method is called after the order has been sent to the hotel supplier and sent back
 private void confirmOrder(Order orderToConfirm)
 {
     //handle the confirmation from the hotel supplier
     Console.WriteLine(orderToConfirm);
 }
示例#5
0
        //Takes an order decrypts it and creates a new thread to submit the order
        //to the order processing object
        private void placeOrder(Order orderToPlace){

            //encrypt order the order to string
            string encryptedOrder = Encoder.Encrypt(orderToPlace);
            
            //create thread to place order
            Thread threadToPlaceOrder = new Thread(() => OrderProcessing.addUnProcessedOrder(orderToPlace.HotelSupplierID, encryptedOrder));

            threadToPlaceOrder.Start();

        }