예제 #1
0
        private static void insertNewVehicleToGarage()
        {
            ConsoleUI.PrintToScreen(string.Format("Please enter the following details:{0}", Environment.NewLine));
            string licenseNumber = ConsoleUI.GetField("License number: ", !v_LettersNumbersOnly, v_NumbersOnly);

            if (Garage.IsVehicleInGarage(licenseNumber))
            {
                Garage.ChangeVehicleStatus(licenseNumber, eVehicleStatus.InRepair);
                ConsoleUI.PrintToScreen("STATUS UPDATE: Car already exists in the garage, changing its status to InRepair");
            }
            else
            {
                Vehicle vehicle = setBasicVehicleInfo(licenseNumber);
                setSpecificMembersPerVehicleType(vehicle);
                setVehicleOwnerInfo(out string o_Owner, out string o_Phone);
                if (Garage.AddVehicleToGarage(vehicle, o_Phone, o_Owner))
                {
                    ConsoleUI.PrintToScreen("SUCCESS: Car was successfully inserted to the garage");
                }
                else
                {
                    ConsoleUI.PrintToScreen("ERROR: An error occured while trying to insert the car to the garage");
                }
            }
        }
        private static void addVehicleToGarage()
        {
            string   ownerName;
            string   ownerPhone;
            bool     vehicleIsAlreadyInGarage = false;
            Vehicles vehicleToAdd;

            vehicleToAdd = AddNewVehicleFromUser();

            Console.WriteLine("please enter Name of vehicle owner");

            ownerName = Console.ReadLine();

            Console.WriteLine("please enter phone of vehicle owner");

            ownerPhone = Console.ReadLine();

            vehicleIsAlreadyInGarage = ObjectOfGarage.AddVehicleToGarage(vehicleToAdd, ownerPhone, ownerName);

            if (vehicleIsAlreadyInGarage == true)
            {
                Console.WriteLine(string.Format("{0}" +
                                                "There is already found in the garage,{0}"
                                                + "Changing status to in-progress",
                                                Environment.NewLine));
            }

            else
            {
                Console.WriteLine("Vehicle was added succesfully");
            }
        }