Esempio n. 1
0
        private static void Stats(GarageHandler handler)
        {
            Console.WriteLine($"{handler.SelectedGarage}'s stats:");
            var vehicletypes = handler.GetAllVehicleTypes();
            var vehicles     = handler.GetSelectedVehicles();

            foreach (var item in vehicletypes)
            {
                Console.WriteLine($"{item}s: {vehicles.Where(x => x.ToString().StartsWith(item)).Count()}");
            }
        }
Esempio n. 2
0
        private static void AddVehicle(GarageHandler handler)
        {
            if (handler.SelectedGarageVehicleCount >= handler.SelectedGarageCapacity)
            {
                Console.WriteLine("The garage is full.");
                return;
            }
            Console.WriteLine("Please select a vehicle type:");
            var types = handler.GetAllVehicleTypes().ToList();

            types.Add("-Cancel-");
            var sel = Menu(types.ToArray());

            if (sel >= types.Count - 1)
            {
                return;
            }

            var selected = types[sel];
            var form     = handler.GetVehicleForm(selected);

            // TODO: FormEntry edit view that allows you to see all fields and switch between them as you please?

            int i = 0;

            Console.WriteLine("Please enter the following values:");
            foreach (var item in form.Fields)
            {
                if (item is Field <string> strfield)
                {
                    strfield.Entry = FormEntry(strfield.Name, strfield.Entry);
                }
                else if (item is Field <int> intfield)
                {
                    intfield.Entry = FormEntry(intfield.Name, intfield.Entry);
                }
                i++;
            }
            handler.CreateVehicle(form);
        }