/// <summary> /// Adding of new user /// </summary> private static void AddNewUser() { string login; string password; Console.WriteLine("Write login for new user:"******"Password: "******"Enter 0 to stop adding 1 to add new role to user any other symbol to show available roles"); int c = Console.Read(); switch (c) { case 0: { adding = false; break; } case 1: { Console.WriteLine("Enter roles id:"); int roleid = Convert.ToInt32(Console.ReadLine()); if (UserControls.AddUsersRole(user.Id, roleid)) { Console.WriteLine("Role added successfully"); } else { Console.WriteLine("Something went wrong maybe id is incorrect"); } break; } default: { break; } } } }
/// <summary> /// Login interface /// </summary> /// <param name="count">Counter of tries</param> /// <returns>User if logged null if not</returns> static private User Login(int count) { try { Console.WriteLine("login:"******"password:"******"*"); } else { if (key.Key == ConsoleKey.Backspace && password.Length > 0) { password = password.Substring(0, (password.Length - 1)); Console.Write("\b \b"); } } } // Stops Receving Keys Once Enter is Pressed while (key.Key != ConsoleKey.Enter); Console.WriteLine(); if (UserControls.Identify(login, password) == null) { if (count < 3) { Console.WriteLine("Wrong login or password"); Console.WriteLine("Press 0 to exit"); string message = "You have only " + (3 - count).ToString() + " more attempts"; Console.WriteLine(message); char choice = Convert.ToChar(Console.ReadLine()); switch (choice) { case '0': { Environment.Exit(0); return(new User()); } default: { return(Login(count + 1)); } } } else { Environment.Exit(0); return(new User()); } } return(UserControls.Identify(login, password)); } catch (FormatException) { return(Login(count + 1)); } }