Ejemplo n.º 1
0
        public bool DeleteFromCarDirectory(string carName)                   // Remove
        {
            CarInformation car = ViewCarDirectoryByCarName(carName);

            if (car == null)
            {
                return(false);
            }
            else
            {
                _carDirectory.Remove(car);
                return(true);
            }
        }
Ejemplo n.º 2
0
        public void AddCarToDirectory()
        {
            Console.Clear();

            Console.WriteLine("What is the name of the car?\n");
            string carName = Console.ReadLine();

            Console.WriteLine("\nWhat is the type of car?\n" +
                              "1. Electric\n" +
                              "2. Gas\n" +
                              "3. Hybrid"
                              );

            string carTypeChoice = Console.ReadLine();

            CarType carType = CarType.Electric;

            switch (carTypeChoice)
            {
            case "1":
                carType = CarType.Electric;
                break;

            case "2":
                carType = CarType.Gas;
                break;

            case "3":
                carType = CarType.Hybrid;
                break;

            default:
                Console.WriteLine("\nPlease select a valid option");
                Console.ReadKey();
                AddCarToDirectory();
                break;
            }

            Console.WriteLine("\nPlease write any additional notes that you would like to save on this car. You can update your notes anytime.\n");
            string carDescription = Console.ReadLine();

            CarInformation cars = new CarInformation(carName, carType, carDescription);

            _repo.AddCarToDirectory(cars);

            Console.WriteLine("\nThank you for adding a new car the Car Directory!");
            Console.ReadKey();
            RunMenu();
        }
Ejemplo n.º 3
0
        public bool UpdateCarByCarName(string carName, CarInformation newCar) // UPDATE Using a bool, because if we try to update content that isn't there then we want it to be able to tell us FALSE
        {
            CarInformation car = ViewCarDirectoryByCarName(carName);          // We are using a Method we created (GCBT)(lines 35-44) to grab the title content we want

            if (car == null)                                                  // If we can't find content then return false
            {
                return(false);
            }
            else
            {
                car.CarName        = newCar.CarName;
                car.CarType        = newCar.CarType;
                car.CarDescription = newCar.CarDescription;
                return(true);
            }
        }
Ejemplo n.º 4
0
        public void UpdateCarDirectory()
        {
            Console.Clear();

            Console.WriteLine("Please enter the car NAME that you would like to UPDATE.");
            string carName = Console.ReadLine();

            Console.WriteLine("Please select the new car TYPE.\n" +
                              "1. Electric\n" +
                              "2. Gas\n" +
                              "3. Hybrid");

            string carTypeChoice = Console.ReadLine();

            CarType carType = CarType.Electric;

            switch (carTypeChoice)
            {
            case "1":
                carType = CarType.Electric;
                break;

            case "2":
                carType = CarType.Gas;
                break;

            case "3":
                carType = CarType.Hybrid;
                break;

            default:
                Console.WriteLine("\nPlease select a valid option");
                Console.ReadKey();
                AddCarToDirectory();
                break;
            }

            Console.WriteLine("Please enter new DETAILS of the car.");
            string carDescription = Console.ReadLine();

            CarInformation newCarName = new CarInformation(carName, carType, carDescription);

            _repo.UpdateCarByCarName(carName, newCarName);

            Console.WriteLine("Thank you for UPDATING the Car Directory");
            Console.ReadKey();
        }
Ejemplo n.º 5
0
 public void AddCarToDirectory(CarInformation item)                  // CREATE
 {
     _carDirectory.Add(item);
 }
Ejemplo n.º 6
0
 public void DisplayContent(CarInformation car)
 {
     Console.WriteLine($"Name: {car.CarName}\n" +
                       $"Car Type: {car.CarType}\n" +
                       $"Car Details: {car.CarDescription}\n\n");
 }