Ejemplo n.º 1
0
        public void ShowMenu()
        {
            var isRunning = true;

            while (isRunning)
            {
                Console.WriteLine("Welcome to the best store ever!");
                foreach (var section in SubSections)
                {
                    Console.WriteLine($"{section.Section.ToString("d")}. {section.Title}");
                }
                foreach (var product in Products)
                {
                    Console.WriteLine($"{product.Id}. {product.Name}");
                }
                Console.WriteLine("0. Exit");

                var userInput = Console.ReadLine();
                int intUserInput;
                var isSuccessful = int.TryParse(userInput, out intUserInput);
                if (!isSuccessful)
                {
                    Console.WriteLine($"Please enter a number between 1 and {SubSections.Count()}");
                }
                else
                {
                    if (intUserInput == 0)
                    {
                        isRunning = false;
                    }
                }
                var enumUserInput = (SectionId)intUserInput;
                Console.WriteLine($"You chose {userInput}: {enumUserInput}");
                var subsection = SubSections.FirstOrDefault(s => s.Section == enumUserInput);
                subsection.ShowMenu();
            }
        }
Ejemplo n.º 2
0
 internal MemberSubSection SubSectionOfSignature(string sig)
 {
     return(SubSections.FirstOrDefault(section => section.SignatureList.Contains(sig)));
 }