コード例 #1
0
        public void Run()
        {
            while (true)
            {
                int result = view.GetMenuChoice("Choose 1 of 5 options: 1 for Create, 2 for List All, 3 for Find By Id, 4 for Edit and 5 for Remove:");
                switch (result)
                {
                case 1:
                    CreateDvd();
                    Success();
                    break;

                case 2:
                    DisplayDvds();
                    Success();
                    break;

                case 3:
                    SearchDvds();
                    Success();
                    break;

                case 4:
                    EditDvd();
                    Success();
                    break;

                case 5:
                    RemoveDvd();
                    Success();
                    break;

                default:
                    break;
                }
                string user_continue_usage_response = view.UserchoiceYesorNo("Do you want to continue to use the application? Enter Yes or No!");
                if (user_continue_usage_response.ToUpper() == "NO")
                {
                    Console.WriteLine("Thanks for using the application!");
                    Console.WriteLine("Press any key to exit the application.");
                    Console.ReadKey();
                    break;                                              //Control goes to the end of the while loop!
                }
                else
                {
                    Console.WriteLine("Good Choice! Enjoy using the application!");
                }
            }
        }
コード例 #2
0
        public void Run() //TO DO: use while loop
        {
            Console.WriteLine("Welcome To Dvd Manager");

            bool inChoice = false;

            while (!inChoice)
            {
                DvdView view = new DvdView();
                int     pass = view.GetMenuChoice();

                if (pass == 1)
                {
                    inChoice = true;
                    CreateDvd();
                    Console.WriteLine("Press any key to go back.");
                    Console.ReadKey();
                    inChoice = false;
                }
                else if (pass == 2)
                {
                    inChoice = true;
                    DisplayDvds();
                    Console.WriteLine("Press any key to go back.");
                    Console.ReadKey();
                    inChoice = false;
                }
                else if (pass == 3)
                {
                    inChoice = true;
                    SearchDvds();
                    Console.WriteLine("Press any key to go back.");
                    Console.ReadKey();
                    inChoice = false;
                }
                else if (pass == 4)
                {
                    inChoice = true;
                    var myEditId = new DvdView();
                    var myId     = myEditId.SearchDvd();
                    var id       = _dvds.ReadById(myId); //search in list repo

                    if (id == null)
                    {
                        Console.WriteLine("Not in list.");
                    }
                    else
                    {
                        var getDvd = view.EditDvdInfo(id);
                        EditDvd(myId, getDvd);
                    }
                    Console.WriteLine("Press any key to go back.");
                    Console.ReadKey();
                    inChoice = false;
                }
                else if (pass == 5)
                {
                    inChoice = true;
                    RemoveDvd();
                    Console.WriteLine("Press any key to go back.");
                    Console.ReadKey();
                    inChoice = false;
                }
                else
                {
                    Console.WriteLine("Invalid input.");
                    Console.ReadKey();
                }
            }
        }