// Method to create the menu and allow the user to input a payment type name and account number. public static void CreatePaymentMenu(PaymentTypeManager ptm) { Console.Clear(); //Prompt and then takes payment type Console.WriteLine($"Enter payment type (e.g. AmEx, Visa, Checking)"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string paymentName = Console.ReadLine(); paymentName = NoEmptyAnswers.notAOne(paymentName, "Please Enter a payment type."); int accountNumber = 0; //Prompts and then takes account number do { try{ Console.WriteLine($"Enter Account Number"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); accountNumber = Convert.ToInt32(Console.ReadLine()); // int.TryParse(Console.ReadLine(), out accountNumber); }catch { Console.WriteLine($"Enter Account Number"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); Int32.TryParse(Console.ReadLine(), out accountNumber); } } while (accountNumber == 0); // int accountNumber = int.Parse(Console.ReadLine()); PaymentType newPaymentType = new PaymentType() { accountNumber = accountNumber, name = paymentName }; ptm.AddNewPaymentType(newPaymentType); Console.WriteLine("Payment type added. Press any key to continue."); Console.ReadLine(); }
// Written By : Matt Augsburger // Method displays the Create Customer Menu // Accepts Argument of an instance of CustomerManager // Adds Created Customer to DB public static void CreateCustomerMenu(CustomerManager cm) { Console.Clear(); Console.WriteLine("Enter customer first name"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string firstName = Console.ReadLine(); firstName = NoEmptyAnswers.notAOne(firstName, "Please enter a customer first name"); Console.Clear(); Console.WriteLine("Enter customer last name"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string lastName = Console.ReadLine(); lastName = NoEmptyAnswers.notAOne(lastName, "Please enter a customer last name"); Console.Clear(); Console.WriteLine("Enter customer street address"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string streetAddress = Console.ReadLine(); streetAddress = NoEmptyAnswers.notAOne(streetAddress, "Please enter a customer street address"); Console.Clear(); Console.WriteLine("Enter customer city"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string city = Console.ReadLine(); city = NoEmptyAnswers.notAOne(city, "Please enter a customer city"); Console.Clear(); Console.WriteLine("Enter customer state"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string state = Console.ReadLine(); state = NoEmptyAnswers.notAOne(state, "Please enter a customer state"); Console.Clear(); int postalCode = 0; do { Console.WriteLine("Enter customer postal code"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string stringPostalCode = Console.ReadLine(); stringPostalCode = NoEmptyAnswers.notAOne(stringPostalCode, "Please enter a postal code"); try{ postalCode = Convert.ToInt32(stringPostalCode); } catch { Console.WriteLine("Please enter a five digit postal code."); stringPostalCode = Console.ReadLine(); Int32.TryParse(stringPostalCode, out postalCode); } } while (postalCode == 0); Console.Clear(); Console.WriteLine("Enter customer phone number"); Console.ForegroundColor = ConsoleColor.Red; Console.Write("> "); Console.ResetColor(); string phoneNumber = Console.ReadLine(); phoneNumber = NoEmptyAnswers.notAOne(phoneNumber, "Please enter a customer phone number"); Customer newCustomer = new Customer() { firstName = firstName, lastName = lastName, streetAddress = streetAddress, state = state, city = city, postalCode = postalCode, phoneNumber = phoneNumber }; cm.AddNewCustomer(newCustomer); Console.Clear(); Console.WriteLine($"You have created a customer! {newCustomer.firstName} {newCustomer.lastName} is now in the Bangazon System"); Console.WriteLine("Press any key to continue"); Console.ReadKey(); }