Beispiel #1
0
        public static void orderProcess(OrderObject orderObject, int currentRoomPrice)
        {
            Thread.Sleep(700);
            try
            {
                lock (lockObject)
                {
                    if (orderObject.GetCardNo() >= 5000 && orderObject.GetCardNo() <= 7000)                 // checks for a valid credit card number
                    {
                        int totalPrice = orderObject.GetAmount() * currentRoomPrice + tax + locationCharge; // calculates the total price including tax and location charge and return

                        Console.WriteLine("\nOrder processed for {0}. \nTotal price for {1} rooms with tax and location charge  = ${2} ", orderObject.GetSenderId(), orderObject.GetAmount(), totalPrice);
                        Console.WriteLine("Time taken for processing in seconds : " + (DateTime.Now - orderObject.creationTime).TotalSeconds + "\n");
                        // TravelAgency.orderConfirmation(orderObject);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error occurred in process order method " + e.Message);
            }
        }
Beispiel #2
0
        public static String encode(OrderObject orderObject) // encodes the message and sends it back to the user

        {
            try
            {
                lock (encodeLock)
                {
                    byte[] encodebyte;
                    string order = orderObject.GetSenderId().ToString() + "#" + orderObject.GetCardNo().ToString() + "#" + orderObject.GetAmount().ToString() + "#" + orderObject.creationTime;
                    encodebyte = ASCIIEncoding.ASCII.GetBytes(order);
                    return(Convert.ToBase64String(encodebyte));
                }
            }
            catch (Exception e)
            {
                return(string.Empty);
            }
        }