public void AddCustomer() { Console.Clear(); bool addLoop = true; Console.WriteLine("Enter the Customer's First Name:\t"); string firstName = Console.ReadLine(); Console.WriteLine("\nEnter the Customer's Last Name:\t"); string lastName = Console.ReadLine(); while (addLoop) { Console.WriteLine("\n What is the Customer's status:\n" + "1. Potential\n" + "2. Current\n" + "3. Past\n"); string response = Console.ReadLine(); Console.Clear(); CustomerType type; string email = ""; Customer customer; switch (response) { case "1": type = CustomerType.Potential; addLoop = false; email = GetEmail(type); customer = new Customer(firstName, lastName, type, email); customerRepo.AddToList(customer); Console.Clear(); break; case "2": type = CustomerType.Current; addLoop = false; email = GetEmail(type); customer = new Customer(firstName, lastName, type, email); customerRepo.AddToList(customer); Console.Clear(); break; case "3": type = CustomerType.Past; addLoop = false; email = GetEmail(type); customer = new Customer(firstName, lastName, type, email); customerRepo.AddToList(customer); Console.Clear(); break; default: Console.WriteLine("Error: Select defined option"); break; } } }
private void AddCustomer() { Console.Clear(); bool trying = true; Console.WriteLine("\nEnter the Customer's First Name:\t"); string firstName = Console.ReadLine(); Console.WriteLine("\nEnter the Customer's Last Name:\t"); string lastName = Console.ReadLine(); while (trying) { Console.WriteLine("\nSelect the Customer's status:\n" + "[1] Potential\n" + "[2] Current\n" + "[3] Past\n"); System.ConsoleKeyInfo key = Console.ReadKey(); Console.Clear(); string response = key.KeyChar.ToString(); CustomerType type; string email = ""; Customer customer; switch (response) { case "1": type = CustomerType.Potential; trying = false; email = GetEmail(type); customer = new Customer(firstName, lastName, type, email); _customerRepo.AddToList(customer); Console.Clear(); break; case "2": type = CustomerType.Current; trying = false; email = GetEmail(type); customer = new Customer(firstName, lastName, type, email); _customerRepo.AddToList(customer); Console.Clear(); break; case "3": type = CustomerType.Past; trying = false; email = GetEmail(type); customer = new Customer(firstName, lastName, type, email); _customerRepo.AddToList(customer); Console.Clear(); break; default: Console.WriteLine("Error: Select defined option"); break; } } }