/*---------------------------------------------------------- * DIFFERENT MENUES * ----------------------------------------------------------*/ public static void StartMenu(List <Classmates> listOfClassmates) { do { Console.Clear(); FileHandling.LogoPrint("start"); PrintMenu(startMenu); Print.Blue(@"Ange ett alternativ \>"); int menuChoice; int.TryParse(Console.ReadLine(), out menuChoice); switch (menuChoice) { case 1: Menus.ListAllClassmates(listOfClassmates); break; case 2: Menus.ListDetailsClassmates(listOfClassmates, listBasicClassmatesMenu); break; case 3: RemoveMenu(listOfClassmates, listBasicClassmatesMenu); break; case 4: listOfClassmates.Clear(); Classmates.Populate(listOfClassmates); FileHandling.BinarySerializer(listOfClassmates); top = startMenu.Count + 11; left = 0; Console.SetCursorPosition(left, top); Print.Yellow("Mockdata återställd"); Thread.Sleep(1500); break; case 5: Environment.Exit(0); break; case 0: default: top = startMenu.Count + 11; left = 0; Console.SetCursorPosition(left, top); Print.Red("Felaktigt val, försök igen"); Thread.Sleep(1500); break; } } while (true); }
// Menu for removing persons public static void RemoveMenu(List <Classmates> listOfClassmates, List <string> menuList) { do { top = menuList.Count + 5; left = 35; FileHandling.LogoPrint("remove"); PrintMenu(menuList); Console.SetCursorPosition(left, top); Print.Yellow($"Välj person att ta bort:"); for (int i = 0; i < listOfClassmates.Count; i++) { top++; Console.SetCursorPosition(left, top); Console.WriteLine($"{i + 1}. {listOfClassmates[i].Name}"); } if (listOfClassmates.Count == 0) { Console.SetCursorPosition(left, top); Print.Yellow("Inga personer finns i klassen"); } top = menuList.Count + 11; left = 0; Console.SetCursorPosition(left, top); Print.Blue(@"Ange ett alternativ \>"); string userInput = Console.ReadLine().ToLower(); int convertedInput = 100; try { convertedInput = Convert.ToInt32(userInput); } catch { switch (userInput) { case "b": StartMenu(listOfClassmates); break; case "a": Environment.Exit(0); break; default: top = listAllClassmatesMenu.Count + 12; left = 0; Console.SetCursorPosition(left, top); Print.Red("Felaktigt val, försök igen"); Thread.Sleep(1500); break; } } if (convertedInput != 100) { switch (convertedInput) { case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: if (convertedInput > listOfClassmates.Count) { Console.SetCursorPosition(left, top); Print.Red("Felaktigt val, försök igen"); } else { listOfClassmates.RemoveAt(convertedInput - 1); FileHandling.BinarySerializer(listOfClassmates); } break; default: top = listAllClassmatesMenu.Count + 12; left = 0; Console.SetCursorPosition(left, top); Print.Red("Felaktigt val, försök igen"); Thread.Sleep(1500); break; } } } while (true); }