コード例 #1
0
        /// <summary>
        /// Add flight to flight id collection in customer object
        /// </summary>
        /// <param name="_customerList"></param>
        public void AddFlight(List <Customer> _customerList)
        {
            String   _loopFlightId = "";
            String   _flightId, _customerId;
            Customer _customer = new Customer();

            do
            {
                Console.WriteLine("Enter the customer id: ");
                _customerId = Console.ReadLine();
                if (!Validator.IsCustomerIdExisted(_customerId))
                {
                    Console.WriteLine("Customer id is not existed! Please enter again. ");
                    continue;
                }
                break;
            } while (true);

            foreach (Customer c in _customerList)
            {
                if (c.Id.Equals(_customerId))
                {
                    _customer = c;
                    break;
                }
            }

            do
            {
                Console.WriteLine("Enter the flight id: ");
                _flightId = Console.ReadLine();
                if (!Validator.IsFlightIdExisted(_flightId))
                {
                    Console.WriteLine("This flight id is not existed ! Please enter again.");
                    continue;
                }
                FlightDAO.GetFlightById(_flightId).CustomerId.Add(_customerId);
                _customer.FlightId.Add(_flightId);
                Console.WriteLine("Add succeed !");
                Console.WriteLine("Do you want to continue entering flight id (Y/N): ");
                _loopFlightId = Console.ReadLine();
            } while (_loopFlightId[0] == 'Y' || _loopFlightId[0] == 'y');
        }