private void RemoveUnit() { // NOT THREAD SAFE!!! MenuSelection menuSelection = new MenuSelection(); menuSelection.Headline = "Vælg Enhed"; menuSelection.SelectionMessage = "Vælg den enhed der skal fjernes fra systemet"; List <Unit> units = unitManager.GetAllunits(); menuSelection.AddOption(units); int selection = menuSelection.RequestSelection(); if (selection == 0) { return; } selection--; // zero index correction Console.WriteLine("Er du sikker på at du vil slette følgende enhed fra systemet?"); Console.WriteLine(units[selection].GetDesignation()); ConsoleKeyInfo key = Console.ReadKey(); if (key.Key == ConsoleKey.Y) { unitManager.RemoveUnit(selection); } }
private void RemoveUser() { List <User> users = new List <User>(); users = userManager.GetAllUsers(); MenuSelection menuSelection = new MenuSelection(); menuSelection.Headline = "Vælg bruger"; menuSelection.SelectionMessage = "Vælg den bruger der skal fjernes fra systemet"; menuSelection.AddOption(users); int selection = menuSelection.RequestSelection(); if (selection == 0) { return; } selection--; // correcting to zero index User user = users[selection]; Console.WriteLine("Er du sikker på at du ønsker at fjerne følgende bruger fra systemet?"); Console.WriteLine(user.Name); ConsoleKeyInfo key = Console.ReadKey(); if (key.Key == ConsoleKey.Y) { userManager.Remove(user); } }
/// <summary> /// Showing the console user interface /// </summary> public void RunMain() { MenuSelection ms = new MenuSelection(); ms.Headline = "Hovedmenu - " + school.Name + " Udlånssystem"; ms.SelectionMessage = "Vælg handling"; ms.AddOption("Udlån udstyr"); ms.AddOption("Modtag udstyr retur"); ms.AddOption("Vedligehold udstyr"); ms.AddOption("Administrer udstyr"); ms.AddOption("Administrer lånere"); ms.AddOption("Afslut program"); int svar; while (true) { svar = ms.RequestSelection(); switch (svar) { case 0: return; case 1: loanScreen.CreateLoan(); break; case 2: loanScreen.EndLoan(); break; case 3: unitScreen.Service(); break; case 4: unitScreen.ManageUnits(); break; case 5: userScreen.ManageUsers(); break; case 6: Environment.Exit(0); break; default: continue; } } }
internal void EndLoan() { List <Unit> units = loanManager.GetLoanedUnits(); MenuSelection loanSelection = new MenuSelection(); loanSelection.Headline = "Vælg lån"; loanSelection.SelectionMessage = "Vælg returneret enhed fra listen"; loanSelection.AddOption(units); int selection = loanSelection.RequestSelection(); if (selection == 0) { return; } selection--; // zero index correction loanManager.EndLoan(units[selection]); }
internal void Service() { List <Unit> units = unitManager.GetUnitsForService(); MenuSelection unitSelection = new MenuSelection(); unitSelection.Headline = "Vælg Enhed"; unitSelection.SelectionMessage = "Vælg den enhed der udføres vedligeholdelse på"; unitSelection.AddOption(units); int selection = unitSelection.RequestSelection(); if (selection == 0) { return; } selection--; // zero index correction Console.WriteLine("Der registreres nu udført vedligehold på " + units[selection].GetDesignation()); unitManager.RegisterService(units[selection]); Console.WriteLine("Der er nu registreret vedligehold på enheden."); Console.ReadKey(); }
private void RegisterNewUnit() { MenuSelection menuSelection = new MenuSelection(); menuSelection.Headline = "Vælg Type"; menuSelection.SelectionMessage = "Vælg typen af enheder"; menuSelection.AddOption("Laptop"); menuSelection.AddOption("Headset"); int selection = menuSelection.RequestSelection(); switch (selection) { case 0: return; case 1: RegisterNewLaptop(); break; case 2: RegisterNewHeadset(); break; } }
internal void ManageUnits() { MenuSelection menuSelection = new MenuSelection(); menuSelection.Headline = "Vælg administration af enheder"; menuSelection.SelectionMessage = "Vælg en af nedenstående handlinger"; menuSelection.AddOption("Tilføj ny enhed"); menuSelection.AddOption("Slet eksisterende enhed"); int selection = menuSelection.RequestSelection(); switch (selection) { case 0: return; case 1: RegisterNewUnit(); break; case 2: RemoveUnit(); break; } }
internal void CreateLoan() { List <User> users = loanManager.GetAvailableUsers(); MenuSelection userSelection = new MenuSelection(); userSelection.Headline = "Vælg låner"; userSelection.SelectionMessage = "Vælg låneren fra følgende liste"; userSelection.AddOption(users); int selectedUser = userSelection.RequestSelection(); if (selectedUser == 0) { return; } selectedUser--; // zero index correction List <Unit> units = loanManager.GetAvailableUnits(); MenuSelection unitSelection = new MenuSelection(); unitSelection.Headline = "Vælg enhed"; unitSelection.SelectionMessage = "Vælg enheden fra følgende ledige enheder"; unitSelection.AddOption(units); int selectedUnit = unitSelection.RequestSelection(); if (selectedUnit == 0) { return; } selectedUnit--; // zero index correction loanManager.CreateLoan(users[selectedUser], units[selectedUnit]); Console.Clear(); Console.WriteLine(users[selectedUser].Name + " har nu lånt " + units[selectedUnit].GetDesignation()); Console.ReadKey(); }