Esempio n. 1
0
        /// <summary>
        /// The Function that actually processes an order, Validates Order with the BankService and returns a confirmation.
        /// </summary>
        /// <param name="encoded_order_object">The encoded OrderObject string to process as an OrderObject, once it is decoded of course.</param>
        public static void orderProcessor(string encoded_order_object)
        {
            //Decode string into an object:
            OrderObject new_order_object = EnDecoder.Decode(encoded_order_object);

            //Update total amount to account for Sales tax:
            decimal total = BankService.formatCurrency((new_order_object.getAmount() + (new_order_object.getAmount() * SALES_TAX)));

            new_order_object.setAmount(total);

            //Create an encryption service via ASU's Repo:
            Service encryption = new Service();

            //Encrypt the credit card number:
            string encrypted_cc_number = encryption.Encrypt(Convert.ToString(new_order_object.getCardNo()));

            //encrypt the total amount to charge the account:
            string encrypted_amount = encryption.Encrypt(Convert.ToString(new_order_object.getAmount()));

            //Have Bank validate the Account charge given the encrypted credit card number and amount to charge:
            new_order_object.setIsValid(BankService.confirmCreditCard(encrypted_cc_number, encrypted_amount));

            //Get the Travel_agencies ID:
            string travel_agency_id = new_order_object.getSenderID();

            //Encode the Processed Order Object:
            string encoded_processed_order = EnDecoder.Encode(new_order_object);

            //Create a new thread to handle the processed order:
            OrderProcessing.submitProcessedOrderObject(encoded_processed_order, travel_agency_id);
            Thread processed_order_thread = new Thread(() => OrderProcessing.submitProcessedOrderObject(encoded_processed_order, travel_agency_id));

            //Start the thread:
            processed_order_thread.Start();
        }
Esempio n. 2
0
        /// <summary>
        /// This function takes in an OrderObject and "encodes" it into a string format.
        /// </summary>
        /// <param name="orderObj">The OrderObject to encode into a string.</param>
        /// <returns>The "encoded" string representation of the OrderObject passed in.</returns>
        public static String Encode(OrderObject orderObj)
        {
            //Generate the new string to be the "encoded" orderObject:
            string orderObj_toString = orderObj.getSenderID();

            orderObj_toString += (" " + orderObj.getReceiverID());
            orderObj_toString += (" " + orderObj.getCardNo());
            orderObj_toString += (" " + orderObj.getAmount());
            orderObj_toString += (" " + orderObj.getUnitPrice());

            //Return the encoded String of the orderObject passed in:
            return(orderObj_toString);
        }