コード例 #1
0
        private static void ConductInspection()
        {
            Reservation makeAInspection;

            SqlClass.GetAllReservations();
            Console.Clear();
            Console.WriteLine("Registration number: ");
            Console.SetCursorPosition(25, 0);
            string regNumber = Console.ReadLine();
            bool   isBooked  = false;

            foreach (var reservation in Engine.reservationList)
            {
                if (reservation.RegistrationNumber == regNumber)
                {
                    isBooked        = true;
                    makeAInspection = new Reservation(reservation.RegistrationNumber, reservation.Date);

                    break;
                }
            }
            if (isBooked)
            {
                Console.Clear();
                Console.WriteLine("Was the vehicle accepted? (Y/N)");

                ConsoleKeyInfo input = Console.ReadKey(true);
                Inspection     inspectionPlaceHolder = null;
                switch (input.Key)
                {
                case ConsoleKey.Y:
                    inspectionPlaceHolder = new Inspection(regNumber);
                    inspectionPlaceHolder.Approve();

                    break;

                case ConsoleKey.N:
                    inspectionPlaceHolder = new Inspection(regNumber);
                    inspectionPlaceHolder.Failed();
                    break;
                }
                Console.Clear();
                Console.WriteLine("The Inspections has been made");
                SqlClass.SaveInspection(inspectionPlaceHolder);
                Thread.Sleep(2000);
            }
            else
            {
                Console.Clear();
                Console.WriteLine("There is no booking in that particular registration number");
                Thread.Sleep(2000);
            }
        }