public void MainMenu() { int menu = 1; while (true) { List <string> mainMenu = new List <string> { "Sign in", "Sign up", "Exit" }; int i = 0; foreach (var item in mainMenu) { i++; if (i == menu) { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; Console.WriteLine(item); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; continue; } Console.WriteLine(item); } ConsoleKeyInfo key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.UpArrow: menu--; if (menu == 0) { menu = 3; } break; case ConsoleKey.DownArrow: menu++; if (menu == 4) { menu = 1; } break; case ConsoleKey.Enter: if (menu == 1) { WorkerMenu(Registation.SignIn(userList) as Worker); } else if (menu == 2) { userList.Add(Registation.SignUp()); } break; } Console.Clear(); } }
public void MainMenu() { int menu = 1; while (true) { List <string> mainMenu = new List <string> { "Sign in", "Sign up", "Exit" }; int i = 0; foreach (var item in mainMenu) { i++; if (i == menu) { Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; Console.WriteLine(item); Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; continue; } Console.WriteLine(item); } ConsoleKeyInfo key = Console.ReadKey(); switch (key.Key) { case ConsoleKey.UpArrow: menu--; if (menu == 0) { menu = 3; } break; case ConsoleKey.DownArrow: menu++; if (menu == 4) { menu = 1; } break; case ConsoleKey.Enter: if (menu == 1) { var a = Registation.SignIn(userList); if (a.Stat == 1) { WorkerMenu(a as Worker); } else { EmployerMenu(a as Employer); } } else if (menu == 2) { userList.Add(Registation.SignUp()); } else if (menu == 3) { StringBuilder stringBuilderEmployer = new StringBuilder(); StringBuilder stringBuilderWorker = new StringBuilder(); List <Worker> listWorker = new List <Worker>(); List <Employer> listEmployer = new List <Employer>(); foreach (var item in userList) { if (item.Stat == 1) { listWorker.Add(item as Worker); } else { listEmployer.Add(item as Employer); } } Console.WriteLine(stringBuilderEmployer); Console.WriteLine(stringBuilderWorker); using (FileStream stream = new FileStream("Worker.json", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { StreamWriter streamWriter = new StreamWriter(stream); var a = JsonConvert.SerializeObject(listWorker); streamWriter.WriteLine(a); streamWriter.Close(); } using (FileStream stream = new FileStream("Employer.json", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { StreamWriter streamWriter = new StreamWriter(stream); var a = JsonConvert.SerializeObject(listEmployer); streamWriter.WriteLine(a); streamWriter.Close(); } return; } break; } Console.Clear(); } }