public void AddNewCar()
        {
            Console.Clear();
            GreenPlanContent newContent = new GreenPlanContent();

            Console.WriteLine("Enter the type of Vehicle\n" +
                              "Gas.\n" +
                              "Hybrid.\n" +
                              "Electric");
            newContent.CarType = Console.ReadLine();
            Console.WriteLine("Enter a name for the vehicle.");
            newContent.CarName = Console.ReadLine();

            Console.WriteLine("Enter the estimated price for this vehicle");
            string priceEstimateAsString = Console.ReadLine();
            double priceEstimateAsDouble = double.Parse(priceEstimateAsString);

            newContent.PriceEstimate = priceEstimateAsDouble;

            Console.WriteLine("Enter fuel cost for this vehicle (per tank/battery)");
            string fuelCostAsString = Console.ReadLine();
            double fuelCostAsDouble = double.Parse(fuelCostAsString);

            newContent.FuelCost = fuelCostAsDouble;
            bool wasAdded = _repo.AddContentToDirectory(newContent);

            if (wasAdded == true)
            {
                Console.WriteLine("Your content was succesfully added.");
            }
            else
            {
                Console.WriteLine("Oops something went wrong. Your content was not added.");
            }
        }
 public void DisplayContent(GreenPlanContent content)
 {
     Console.WriteLine($"Car Type {content.CarType}");
     Console.WriteLine($"Car Name {content.CarName}");
     Console.WriteLine($"Price of Vehicle {content.PriceEstimate}");
     Console.WriteLine($"Cost per tank/battery {content.FuelCost}");
     Console.WriteLine($"Estimated Mileage for 1 Tank {content.Mileage}");
 }
        public void DeleteVehicleByName()
        {
            Console.WriteLine("Enter the name of the person you would like to delete");
            string firstNameToDelete = Console.ReadLine();

            GreenPlanContent contentToDelete = _repo.FindCarByName(firstNameToDelete);
            bool             wasDeleted      = _repo.DeleteVehicleByName(contentToDelete);

            if (wasDeleted)
            {
                Console.WriteLine("This vehicle was successfully deleted");
            }
            else
            {
                Console.WriteLine("Vehiclle could not be deleted");
            }
        }
        public void UpdateExistingContent()
        {
            Console.Clear();
            Console.WriteLine("Enter the name of the vehicles's data you'd like to update.");
            string           cartype = Console.ReadLine();
            GreenPlanContent oldItem = _repo.FindCarByName(cartype);

            if (oldItem == null)
            {
                Console.WriteLine("vehicle not found, press any key to continue...");
                Console.ReadKey();
                return;
            }
            GreenPlanContent newItem = new GreenPlanContent(
                oldItem.CarType,
                oldItem.PriceEstimate,
                oldItem.FuelCost,
                oldItem.Mileage,
                oldItem.CarName

                );

            Console.WriteLine("Which property would you like to update:\n" +
                              "1. CarType\n" +
                              "2. CarName\n" +
                              "3. Price Estimate\n" +
                              "4. Fuel Cost\n" +
                              "5. Mileage\n" +
                              "6. Nevermind");
            string selection = Console.ReadLine();

            switch (selection)
            {
            case "1":
                Console.WriteLine("Enter a car type.\n" +
                                  "Gas\n" +
                                  "Hybrid\n" +
                                  "Electric");
                string newFirstName = Console.ReadLine();
                newItem.CarType = newFirstName;
                bool wasSuccessful = _repo.UpdateExistingContent(cartype, newItem);
                if (wasSuccessful)
                {
                    Console.WriteLine("Car Type successfully updated");
                }
                else
                {
                    Console.WriteLine($"Error: Could not update {cartype}");
                }
                break;

            default:
                break;

            case "2":
                Console.WriteLine("Enter a new car name");
                string newCarName = Console.ReadLine();
                newItem.CarName = newCarName;
                break;

            case "3":
                Console.WriteLine("Enter price estimate");
                string priceEstimateAsString = Console.ReadLine();
                double priceEstimateAsDouble = double.Parse(priceEstimateAsString);
                newItem.PriceEstimate = priceEstimateAsDouble;
                break;

            case "4":
                Console.WriteLine("Enter Vechile fuel cost");
                string fuelCostAsString = Console.ReadLine();
                double fuelCostAsDouble = double.Parse(fuelCostAsString);
                newItem.FuelCost = fuelCostAsDouble;
                break;
            }
        }
예제 #5
0
 public void DisplayContent(GreenPlanContent content)
 {
     Console.WriteLine($"Title: {content.HybridCar}");
     Console.WriteLine($"Description: {content.ElectricCar}");
 }