Ejemplo n.º 1
0
        public void AddNewRentalSubMenu(bool clear = true)
        {
            if (clear)
            {
                Console.Clear();
            }

            Console.WriteLine("### Rent Vehicle Submenu ###\n\n");
            CustomerIDValidInput();
            RegistrationValidInput();
            RentalTimeValidationInput();
            double dailyRate = Fleet.GetVehicle(RegistrationRent).dailyRate;

            if (Fleet.RentVehicle(RegistrationRent, CustomerIDRent, dailyRate))
            {
                string days      = RentalTime.ToString() == "1" ? "day" : "days";
                double TotalCost = dailyRate * RentalTime;
                Console.WriteLine($"\nSuccessfully added customer '{CustomerIDRent}' renting '{RegistrationRent}'" +
                                  $" for '{RentalTime}' {days} with a total cost of {TotalCost.ToString("C")}");
                Fleet.SaveRentalsToFile();
            }
            else
            {
                Console.WriteLine($"\nCannot add customer '{CustomerIDRent}' with '{RegistrationRent}' to the rental list.\n");
            }
            LastMRRCscreen(() => SubMenu("Rentals"), () => AddNewRentalSubMenu());
        }