Exemple #1
0
        internal static void UpdateVehicleMenu(GarageHandler gh, MenuHandler mh)
        {
            mh.menus.Remove("vehicleIndex");
            var items = new List <MenuItem>();

            var    currentGarage = gh.GetCurrentGarage();
            string garageName;

            if (currentGarage != null)
            {
                items      = (List <MenuItem>)MenuConverter.VehiclesToMenuItems(currentGarage.Vehicles);
                garageName = currentGarage.Name;
            }
            else
            {
                garageName = "";
            }

            var labelRow = Vehicle.ToHeader();

            items.Insert(0, new MenuItem(labelRow));

            items.Add(new MenuItem(""));
            items.Add(new MenuItem("Nytt fordon", new MenuAction(Create, "vehicle")));
            items.Add(new MenuItem("Byt namn på garage", new MenuAction(Edit, "garage")));
            items.Add(new MenuItem("Ta bort garage", new MenuAction(Delete, "garage")));

            mh.AddMenu(new Menu("vehicleIndex", garageName + " -> Välj fordon", items));
        }
Exemple #2
0
        internal static void UpdateGroupMenu(GarageHandler gh, MenuHandler mh)
        {
            mh.menus.Remove("allGroupIndex");
            var vehicles = gh.GetCurrentGarage().Vehicles;

            mh.AddMenu(new Menu("allGroupIndex", "Välj grupp",
                                MenuConverter.VehiclesToMenuItemsByGroup(vehicles)));
        }
Exemple #3
0
        internal static void UpdateGroupResult(GarageHandler gh, MenuHandler mh, string typ)
        {
            mh.menus.Remove("groupedVehicleIndex");

            var vehicles = gh.AllVehiclesByType(typ);

            var items = new List <MenuItem>();

            items = (List <MenuItem>)MenuConverter.VehiclesToMenuItems(vehicles);

            mh.AddMenu(new Menu("groupedVehicleIndex", "Fordon inom grupp", items));
        }
Exemple #4
0
        internal static void UpdateGarageMenu(GarageHandler gh, MenuHandler mh)
        {
            mh.menus.Remove("garageIndex");
            var items = (List <MenuItem>)MenuConverter.GaragesToMenuItems(gh.garages);

            mh.AddMenu(new Menu("garageIndex", "Välj garage", items));

            var labelRow = Garage <Vehicle> .ToHeader();

            items.Insert(0, new MenuItem(labelRow, false));

            items.Add(new MenuItem("", true));
            items.Add(new MenuItem("Nytt garage", new MenuAction(Create, "garage")));
        }
Exemple #5
0
        internal static void Search(GarageHandler gh, MenuHandler mh)
        {
            ConsoleHelper.PutLabel("Sökning");
            var text = ConsoleHelper.AskQuestionText("sökterm");
            IEnumerable <Vehicle> found = gh.FindVehicles(text);

            if (found.Any())
            {
                mh.menus.Remove("searchIndex");
                mh.AddMenu(new Menu("searchIndex", "Sökresultat",
                                    MenuConverter.VehiclesToMenuItems(found)));
                mh.TryGotoMenu("searchIndex");
            }
            else
            {
                ConsoleHelper.Announce("Tyvärr, kunde inte hitta något fordon.");
            }
        }