public void Greeting() { Console.WriteLine("--- Welcome to the video store. ---"); Console.Write("Are you a new customer or an existing customer? "); string customerType = Console.ReadLine(); switch (customerType.ToLower()) { default: case "new": _customer.CreateNewCustomer(); break; case "existing": _customer = _customer.LookupCustomer(); break; } bool IsDone = false; Console.WriteLine("Hello {0}, what would you like to do?", _customer.Name); while (!IsDone) { foreach (var option in _mainOptions) { Console.WriteLine(option); } string optionDecision = Console.ReadLine(); switch (optionDecision) { default: case "1": ListAllVideosFromStore(); IsDone = PromptToContinue(); break; case "2": AddVideoToStore(); IsDone = PromptToContinue(); break; case "3": PromptToSearch(); IsDone = PromptToContinue(); break; case "4": DisplayItemsInCart(); break; case "5": ViewPreviousOrders(); break; case "6": IsDone = true; break; } } Console.WriteLine("Thank you for using the video store. See you next time!"); }
public StoreCustomer LookupCustomer() { StoreCustomer customerToReturn = new StoreCustomer(); List <string> LookupOptions = new List <string> { "1) By CustomerID number", "2) By Customer Name" }; Console.WriteLine("How would you like us to find your information?"); foreach (string option in LookupOptions) { Console.WriteLine(option); } string lookupType = Console.ReadLine(); switch (lookupType) { default: case "1": customerToReturn = FindCustomerById(); break; case "2": customerToReturn = FindCustomerByName(); break; } return(customerToReturn); }
public Store() { _videoStore = new VideoStoreEntities(); _mainOptions = new List <string> { "1) View the current videos in the store", "2) Add a new video to the store", "3) Purchase video(s)", "4) View item(s) in cart", "5) View previous orders", "6) Quit" }; _customer = new StoreCustomer(); }
private StoreCustomer FindCustomerByName() { bool isFound = false; StoreCustomer customerToReturn = new StoreCustomer(); while (!isFound) { Console.Write("Enter the name to lookup: "); string name = Console.ReadLine(); var results = _videoStore.RetrieveCustomerByName(name); List <RetrieveCustomerByName_Result> resultsList = new List <RetrieveCustomerByName_Result>(); resultsList = (from a in results select a).ToList(); int count = 1; if (resultsList.Count == 0) { Console.WriteLine("No results found for the name {0}. Please try again.", name); } else if (resultsList.Count == 1) { customerToReturn.Name = resultsList[0].CustomerName; customerToReturn.Email = resultsList[0].CustomerEmail; customerToReturn.PhoneNumber = resultsList[0].CustomerPhone; customerToReturn.CustomerId = resultsList[0].CustomerId; isFound = true; } else { Console.WriteLine("{0} results found for the name {1}. Please select which one is you.", resultsList.Count, name); foreach (var result in resultsList) { Console.WriteLine("{0}) {1} | {2} | {3}", count, result.CustomerName, result.CustomerEmail, result.CustomerPhone); count++; } int customerDecision = int.Parse(Console.ReadLine()) - 1; customerToReturn.Name = resultsList[customerDecision].CustomerName; customerToReturn.Email = resultsList[customerDecision].CustomerEmail; customerToReturn.PhoneNumber = resultsList[customerDecision].CustomerPhone; customerToReturn.CustomerId = resultsList[0].CustomerId; isFound = true; } } return(customerToReturn); }