private static string EnterDataToRegister(string input) { Console.WriteLine("\nPlease enter the following data: \n1 - your username. \n2 - your password. \n3 - your email. \n"); Person person = new Person(); person.Username = Console.ReadLine(); while (true) { if (!IsUsernameValid(person.Username)) { Console.WriteLine("\nCan't accept this username. Try to change blank space to underscore.\n"); person.Username = Console.ReadLine(); } if (!person.Username.Contains(" ")) { break; } } person.Password = Console.ReadLine(); while (true) { if (!IsPasswordValid(person.Password)) { Console.WriteLine("\nCan't accept this password. Try to change blank space to underscore.\n"); person.Password = Console.ReadLine(); } if (!person.Password.Contains(" ")) { break; } } person.Email = Console.ReadLine(); while (true) { if (!IsEmailValid(person.Email)) { Console.WriteLine("\nCan't accept this email. Email must end with '.com' and must contain '@'.\n"); person.Email = Console.ReadLine(); } if (person.Email.EndsWith(".com") || person.Email.Contains("@")) { break; } } PersonDatabase personDatabase = new PersonDatabase(); personDatabase.TryAddPerson(person); return(Console.ReadLine()); }
private static string EnterDataToLogin(string input) { Console.WriteLine("\nPlease enter the following data: \n1 - your username. \n2 - your password. \n"); string username = Console.ReadLine(); string password = Console.ReadLine(); Person person = new Person(); PersonDatabase personDatabase = new PersonDatabase(); while (true) { if (personDatabase.ChechForAPerson(username) == true) { Console.WriteLine("\nSuccess"); break; } else { Console.WriteLine("\nPlease try again. Enter your username and password: \n"); username = Console.ReadLine(); password = Console.ReadLine(); } } return(Console.ReadLine()); }