public Salesperson DisplaySetupAccount() { Salesperson salesperson = new Salesperson(); ConsoleUtil.HeaderText = "Account Setup"; ConsoleUtil.DisplayReset(); ConsoleUtil.DisplayMessage("Setup your account now."); ConsoleUtil.DisplayMessage(""); ConsoleUtil.DisplayPromptMessage("Enter your first name: "); salesperson.FirstName = Console.ReadLine(); ConsoleUtil.DisplayMessage(""); ConsoleUtil.DisplayPromptMessage("Enter your last name: "); salesperson.LastName = Console.ReadLine(); ConsoleUtil.DisplayMessage(""); ConsoleUtil.DisplayPromptMessage("Enter your account ID: "); salesperson.AccountID = Console.ReadLine(); ConsoleUtil.DisplayMessage(""); ConsoleUtil.DisplayMessage("Product Types"); ConsoleUtil.DisplayMessage(""); foreach (string productTypeName in Enum.GetNames(typeof(Product.ProductType))) { if (productTypeName != Product.ProductType.None.ToString()) { ConsoleUtil.DisplayMessage(productTypeName); } } ConsoleUtil.DisplayMessage(""); ConsoleUtil.DisplayPromptMessage("Greetings Potion Seller. Please enter the product type you wish to sell today: "); Product.ProductType productType; if (Enum.TryParse <Product.ProductType>(UppercaseFirst(Console.ReadLine()), out productType)) { salesperson.CurrentStock.Type = productType; } else { salesperson.CurrentStock.Type = Product.ProductType.None; } if (ConsoleValidator.TryGetIntegerFromUser(0, 100, 3, "products", out int numberOfUnits)) { salesperson.CurrentStock.AddProducts(numberOfUnits); } else { ConsoleUtil.DisplayMessage("It appears you are having difficulty setting the number of products in your stock."); ConsoleUtil.DisplayMessage("By default, the number of products in your inventory are now set to zero."); salesperson.CurrentStock.AddProducts(0); DisplayContinuePrompt(); } ConsoleUtil.DisplayMessage(""); ConsoleUtil.DisplayReset(); ConsoleUtil.DisplayMessage("Your account has been setup"); DisplayContinuePrompt(); return(salesperson); }
/// <summary> /// get the menu choice from the user /// </summary> public MenuOption DisplayGetUserMenuChoice() { MenuOption userMenuChoice = MenuOption.None; bool usingMenu = true; while (usingMenu) { ConsoleUtil.DisplayReset(); Console.CursorVisible = false; ConsoleUtil.DisplayMessage("Please type the number of your menu choice."); ConsoleUtil.DisplayMessage(""); Console.Write( "\t" + "1. Travel" + Environment.NewLine + "\t" + "2. Buy" + Environment.NewLine + "\t" + "3. Sell" + Environment.NewLine + "\t" + "4. Display Inventory" + Environment.NewLine + "\t" + "5. Display Cities" + Environment.NewLine + "\t" + "6. Display Account Info" + Environment.NewLine + "\t" + "E. Exit" + Environment.NewLine); ConsoleKeyInfo userResponse = Console.ReadKey(true); switch (userResponse.KeyChar) { case '1': userMenuChoice = MenuOption.Travel; usingMenu = false; break; case '2': userMenuChoice = MenuOption.Buy; usingMenu = false; break; case '3': userMenuChoice = MenuOption.Sell; usingMenu = false; break; case '4': userMenuChoice = MenuOption.DisplayInventory; usingMenu = false; break; case '5': userMenuChoice = MenuOption.DisplayCities; usingMenu = false; break; case '6': userMenuChoice = MenuOption.DisplayAccountInfo; usingMenu = false; break; case 'E': case 'e': userMenuChoice = MenuOption.Exit; usingMenu = false; break; default: ConsoleUtil.DisplayMessage( "That is not a valid imput. Please enter a valid input." + Environment.NewLine + "Press any key to continue or the E key to quit the application."); userResponse = Console.ReadKey(true); if (userResponse.Key == ConsoleKey.Escape) { usingMenu = false; } break; } } Console.CursorVisible = true; return(userMenuChoice); }