Пример #1
0
        public void RemoveVehicle()
        {
            Console.Clear();
            List <NewCar>         newCars         = NewCars;
            List <UsedCar>        usedCars        = UsedCars;
            List <NewMotorcycle>  newMotorcycles  = NewMotorcycles;
            List <UsedMotorcycle> usedMotorcycles = UsedMotorcycles;

            Menus.PrintRemoveVehicle();


            var removeChoice = Console.ReadKey(true).Key;

            switch (removeChoice)
            {
            case ConsoleKey.D1:
            case ConsoleKey.NumPad1:
                Console.Clear();

                Console.WriteLine("Enter the number of the vehicle you want to remove: ");

                foreach (var newCar in NewCars)
                {
                    Console.WriteLine("{3}. {1}. {2}. {0}", newCar.Brand, newCar.Model, newCar.Price,
                                      Array.IndexOf(newCars.ToArray(), newCar),
                                      newCar);
                }

                var index = int.Parse(Console.ReadLine());
                NewCars.RemoveAt(index);
                Console.WriteLine("Vehicle removed");
                Console.ReadKey(true);



                break;

            case ConsoleKey.D2:
            case ConsoleKey.NumPad2:
                Console.Clear();

                Console.WriteLine("Enter the number of the vehicle you want to remove: ");

                foreach (var usedCar in UsedCars)
                {
                    Console.WriteLine("{3}. {1}. {2}. {0}", usedCar.Brand, usedCar.Model, usedCar.Price,
                                      Array.IndexOf(usedCars.ToArray(), usedCar),
                                      usedCar);
                }
                var index2 = int.Parse(Console.ReadLine());
                UsedCars.RemoveAt(index2);
                Console.WriteLine("Vehicle removed");
                Console.ReadKey(true);

                break;

            case ConsoleKey.D3:
            case ConsoleKey.NumPad3:
                Console.Clear();

                Console.WriteLine("Enter the number of the vehicle you want to remove: ");

                foreach (var newMotorcycle in NewMotorcycles)
                {
                    Console.WriteLine("{3}. {0}. {1}. {2}", newMotorcycle.Brand, newMotorcycle.Model, newMotorcycle.Price,
                                      Array.IndexOf(newMotorcycles.ToArray(), newMotorcycle),
                                      newMotorcycle);
                }
                var index3 = int.Parse(Console.ReadLine());
                NewMotorcycles.RemoveAt(index3);
                Console.WriteLine("Vehicle removed");
                Console.ReadKey(true);
                break;

            case ConsoleKey.D4:
            case ConsoleKey.NumPad4:
                Console.Clear();

                Console.WriteLine("Enter the number of the vehicle you want to remove: ");

                foreach (var usedMotorcycle in UsedMotorcycles)
                {
                    Console.WriteLine("{3}. {1}. {2}. {0}", usedMotorcycle.Brand, usedMotorcycle.Model, usedMotorcycle.Price,
                                      Array.IndexOf(usedMotorcycles.ToArray(), usedMotorcycle),
                                      usedMotorcycle);
                }
                var index4 = int.Parse(Console.ReadLine());
                UsedMotorcycles.RemoveAt(index4);
                Console.WriteLine("Vehicle removed");
                Console.ReadKey(true);
                break;
            }
        }
        public ActionResult Index()
        {
            UsedCars newCar = new UsedCars("1998", "Subaru", "Outback", "231,000", "$3,000");

            return(View(newCar));
        }