private static void ViewCustomersOption() { Console.WriteLine("List of customers: "); foreach (Customer customer in CustomerRepository.GetList()) { Console.WriteLine($" {customer.FullName} ({customer.CustomerType})"); Console.WriteLine($" Email Message: {customer.EmailMessage}"); Console.WriteLine(); } Input("Press enter/return when you're finished viewing this list "); }
public void Run() { _customers = _customerRepo.GetList(); bool isRunning = true; while (isRunning) { Console.WriteLine("Choose an action:" + "\n1. Create new customer" + "\n2. Update customer info" + "\n3. See all customers" + "\n4. Delete customer" + "\n7. Exit"); int input = int.Parse(Console.ReadLine()); switch (input) { case 1: CreateNewCustomer(); break; case 2: UpdateCustomer(); break; case 3: SeeAllCustomers(); break; case 4: RemoveCustomer(); break; case 5: isRunning = false; Console.WriteLine("Goodbye!"); Console.ReadLine(); break; default: Console.WriteLine("Invalid response."); Console.ReadLine(); break; } } }
private static Customer ChooseACustomer(string action_text) { Console.WriteLine($"Choose a customer to {action_text}: "); int counter = 1; foreach (Customer customer in CustomerRepository.GetList()) { Console.WriteLine($" [{counter}] {customer.FullName} ({customer.CustomerType})"); counter++; } while (true) { int input = int.Parse(Input("Input [#]: ")); if (!(input < 1) && !(input > CustomerRepository.GetList().Count)) { return(CustomerRepository.GetList()[input - 1]); } } }
static void Main(string[] args) { CustomerRepository customerRepo = new CustomerRepository(); List <Customer> CustomerRepository = customerRepo.GetList(); Customer customer = new Customer("Jim", "Jones", "Potential"); Console.WriteLine("Welcome to Komodo Insurance"); Console.WriteLine("\n"); Console.WriteLine("Would you like to 1.Add a Customer, 2. Remove an Customer, or 3. List all Customers?"); string choice = Console.ReadLine(); if (choice == "1") { while (true) { Console.WriteLine("Enter the customer's first name:"); int firstName = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the customer's last name:"); var lastName = Console.ReadLine(); Console.WriteLine("Is this a potential, previous or current customer?"); string type = Console.ReadLine(); customer userFood = new Customer(firstName, lastName, type); customerRepo.AddCustomerToList(userCustomer); Console.WriteLine("Do you want to add annother customer?"); string theAnswer = Console.ReadLine(); if (theAnswer == "y") { continue; } else if (theAnswer == "n") { customerRepo.printList(customerRepo.GetList()); break; } } } else if (choice == "2") { Console.WriteLine("Which customer do you want to remove?"); string item = Console.ReadLine(); customerRepo.removeMenuItemFromList(item); customerRepo.printList(customerRepo.GetList()); } else if (choice == "3") { customerRepo.printList(customerRepo.GetList()); } Console.ReadLine(); foRepo.AddMenuItemToList(omelette); foodRepo.AddMenuItemToList(pancakes); foodRepo.AddMenuItemToList(blt); foodRepo.AddMenuItemToList(parfait); foodRepo.AddMenuItemToList(salad); foodRepo.AddMenuItemToList(sub); }
static void Main(string[] args) { CustomerRepository customerRepo = new CustomerRepository(); List <Customer> customerList = customerRepo.GetList(); customerRepo.AddCustomer("John", "Smith", 1); customerRepo.AddCustomer("Jane", "Smith", 2); customerRepo.AddCustomer("John", "Smith", 3); string input = null; while (input != "5") { Console.Clear(); Console.WriteLine($"What would you like to do?" + $"\n1. Add New User" + $"\n2. View all Users" + $"\n3. Update User" + $"\n4. Remove User" + $"\n5. Exit"); input = Console.ReadLine(); if (input == "1") { Console.Clear(); Console.Write("Add new user first name: "); string newFirst = Console.ReadLine(); Console.Write("Add new user last name: "); string newLast = Console.ReadLine(); Console.WriteLine($"Which type is this new user?" + $"\n1. Potential" + $"\n2. Current" + $"\n3. Past"); int valid = 0; int newType = 1; while (valid == 0) { newType = Int32.Parse(Console.ReadLine()); valid = 1; switch (newType) { case 1: break; case 2: break; case 3: break; default: Console.WriteLine("Invalid Input"); valid = 0; break; } } customerRepo.AddCustomer(newFirst, newLast, newType); } else if (input == "2") { Console.Clear(); customerList.Sort((x, y) => string.Compare(x.LastName, y.LastName)); Console.WriteLine("UserID\tFirst\tLast\tCustomer Type\tEmail Sent"); customerRepo.Recount(); foreach (Customer customer in customerList) { string email = null; switch (customer.Type) { case CustomerType.Potential: email = "\tWe currently have the lowest rates on Helicopter Insurance!"; break; case CustomerType.Current: email = "\tThank you for your work with us. We appreciate your loyalty. Here's a coupon."; break; case CustomerType.Past: email = "\tIt's been a long time since we've heard from you, we want you back!"; break; } Console.WriteLine($"{customer} {email}"); } Console.Read(); } else if (input == "3") { Console.Clear(); Console.Write("Enter the customer ID you would like to update: "); int response = Int32.Parse(Console.ReadLine()); if (customerList.Exists(x => x.UserID == response)) { foreach (Customer customer in customerList) { if (customer.UserID == response) { Console.WriteLine($"1. First Name: {customer.FirstName}" + $"\n2. Last Name: {customer.LastName}" + $"\n3. Customer Type: {customer.Type}" + $"\n4. Return to Menu" + $"\n\nEnter the number to update: "); int updateResponse = Int32.Parse(Console.ReadLine()); switch (updateResponse) { case 1: Console.Write("Enter new First Name: "); customer.FirstName = Console.ReadLine(); break; case 2: Console.Write("Enter new Last Name: "); customer.LastName = Console.ReadLine(); break; case 3: Console.WriteLine($"Enter new Customer Type: " + $"\n\t1. Potential" + $"\n\t2. Current" + $"\n\t3. Past"); int updatedType = Int32.Parse(Console.ReadLine()); if (updatedType == 1) { customer.Type = CustomerType.Potential; } else if (updatedType == 2) { customer.Type = CustomerType.Current; } else if (updatedType == 3) { customer.Type = CustomerType.Past; } else { Console.WriteLine("Invalid type."); } break; case 4: Console.WriteLine("Press ENTER to return to main menu"); break; default: Console.WriteLine("Invalid Input"); break; } break; } } } else { Console.WriteLine($"No user exists with that ID."); } Console.ReadLine(); } else if (input == "4") { Console.Clear(); Console.Write("Enter the user's ID you would like to remove: "); int response = Int32.Parse(Console.ReadLine()); if (customerList.Exists(x => x.UserID == response)) { customerRepo.RemoveCustomer(response); Console.WriteLine("User Removed."); } else { Console.WriteLine($"No user exists with that ID."); } Console.ReadLine(); } else if (input == "5") { break; } } customerRepo.RemoveCustomer(2); foreach (Customer customer in customerList) { Console.WriteLine(customer.UserID); } }
public static void ChooseAnOption() { while (true) { Console.WriteLine(divider); Console.WriteLine("What do you want to do?"); Console.WriteLine(" [1] Add a new customer"); Console.WriteLine(" [2] Remove a customer"); Console.WriteLine(" [3] Update a customer"); Console.WriteLine(" [4] View all customers"); Console.WriteLine(" [5] Exit program"); while (true) { string chosen = Input("Input [#]: "); if (chosen == "1") { Console.WriteLine(divider); AddCustomerOption(); break; } else if (chosen == "2") { Console.WriteLine(divider); if (CustomerRepository.GetList().Count > 0) { RemoveCustomerOption(); } else { Console.WriteLine("You need to add a customer first."); Input("Press enter/return "); } break; } else if (chosen == "3") { Console.WriteLine(divider); if (CustomerRepository.GetList().Count > 0) { UpdateCustomerOption(); } else { Console.WriteLine("You need to add a customer first."); Input("Press enter/return "); } break; } else if (chosen == "4") { Console.WriteLine(divider); if (CustomerRepository.GetList().Count > 0) { ViewCustomersOption(); } else { Console.WriteLine("You need to add a customer first."); Input("Press enter/return "); } break; } else if (chosen == "5") { Environment.Exit(1); } } } }