Exemple #1
0
 public void KomodoGreenRepo_AddCar_ShouldNotBeNull()
 {
     Assert.IsNotNull(_carRepo.GetCarByModelId(_car1.ModelId));
 }
        public void CarListUpdate()
        {
            Console.Clear();
            CarsListView();

            Console.WriteLine("Enter the ID of the car list you'd like to update");
            int             existingCarListId = int.Parse(Console.ReadLine());
            KomodoGreenList listToUpdate      = _carListRepo.GetCarListById(existingCarListId);

            Console.WriteLine($"What would you like to update in List ID {listToUpdate.CarListId}? Enter the corresponding number:\n" +
                              $"1. Add car(s) to list\n" +
                              $"2. Remove car from list.\n" +
                              $"3. Update car list type\n");

            string input = Console.ReadLine();

            switch (input)
            {
            case "1":
                CarsView();
                Console.WriteLine($"Please enter the model IDs of the cars you'd like to add to List ID {listToUpdate.CarListId} separated ONLY by commas.");
                List <string> listOfCarIdsAsString = Console.ReadLine().Split(',').ToList();

                var listOfCarsToAdd = new List <KomodoGreen>();

                foreach (string idAsString in listOfCarIdsAsString)
                {
                    int id = int.Parse(idAsString);

                    KomodoGreen carToAdd = _carRepo.GetCarByModelId(id);
                    listOfCarsToAdd.Add(carToAdd);
                }

                listToUpdate.AddCarToList(listOfCarsToAdd);

                Console.WriteLine("To view any changes to car lists, view all car lists in the main menu.");

                break;

            case "2":
                Console.WriteLine($"Please enter the model ID of the car you'd like to delete from List ID {listToUpdate.CarListId}.");
                listToUpdate.RemoveCarFromList(_carRepo.GetCarByModelId(int.Parse(Console.ReadLine())));

                Console.WriteLine("To view any changes to car lists, view all car lists in the main menu.");
                break;

            case "3":
                KomodoGreenList updatedCarList = new KomodoGreenList();

                Console.WriteLine("Enter the number assocated with the updated car list.\n" +
                                  "1. Electric\n" +
                                  "2. Hybrid\n" +
                                  "3. Gas");

                updatedCarList.CarListType = (CarListTypeEnum)int.Parse(Console.ReadLine());

                _carListRepo.UpdateCarList(listToUpdate.CarListId, updatedCarList.CarListType);

                Console.WriteLine("To view any changes to car lists, view all car lists in the main menu.");
                break;

            default:
                Console.WriteLine("You must enter a valid entry. You will be returned to the main menu.");
                break;
            }
        }