예제 #1
0
파일: Program.cs 프로젝트: tollyx/Garaget
        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);
        }