Пример #1
0
        public void ChooseActionForRoom()
        {
            RoomRepository roomRepository = new RoomRepository();
            RoomServices   roomServices   = new RoomServices();

            Console.Clear();
            Console.WriteLine("Repository: ROOM\n\n");
            Console.WriteLine("What action you choose?\n" +
                              "1. View table\n" +
                              "2. Add row\n" +
                              "3. Update row\n" +
                              "4. Delete row\n" +
                              "5. View maximum price\n" +
                              "6. Viev minimum price\n" +
                              "7. Back to start menu");
            Console.Write("\nYour selection: ");

            string ch = Console.ReadLine();

            switch (ch)
            {
            case "1":
            {
                try
                {
                    Console.Clear();
                    Console.WriteLine("Repository: ROOM\n\n");
                    roomRepository.Select(roomRepository.CreateFilter());
                    break;
                }
                finally
                {
                    Menu menu = new Menu();
                    menu.ChooseActionForRoom();
                }
            }

            case "2":
            {
                try
                {
                    Console.Clear();
                    Console.WriteLine("Repository: ROOM\n\n");
                    roomRepository.Add(roomRepository.CreateModel());
                    break;
                }
                finally
                {
                    Menu menu = new Menu();
                    menu.ChooseActionForRoom();
                }
            }

            case "3":
            {
                try
                {
                    Console.Clear();
                    Console.WriteLine("Repository: ROOM\n\n");
                    roomRepository.Update(roomRepository.CreateModel(), roomRepository.CreateFilter());
                    break;
                }
                finally
                {
                    Menu menu = new Menu();
                    menu.ChooseActionForRoom();
                }
            }

            case "4":
            {
                try
                {
                    Console.Clear();
                    Console.WriteLine("Repository: ROOM\n\n");
                    roomRepository.Delete(roomRepository.CreateFilter());
                    break;
                }
                finally
                {
                    Menu menu = new Menu();
                    menu.ChooseActionForRoom();
                }
            }

            case "5":
            {
                try
                {
                    Console.Clear();
                    Console.WriteLine("Repository: ROOM\n\n");
                    Console.WriteLine("MaxPrice: " + roomServices.MaxPrice());
                    Console.ReadKey();
                    break;
                }
                finally
                {
                    Menu menu = new Menu();
                    menu.ChooseActionForRoom();
                }
            }

            case "6":
            {
                try
                {
                    Console.Clear();
                    Console.WriteLine("Repository: ROOM\n\n");
                    Console.WriteLine("MinPrice: " + roomServices.MaxPrice());
                    Console.ReadKey();
                    break;
                }
                finally
                {
                    Menu menu = new Menu();
                    menu.ChooseActionForRoom();
                }
            }

            case "7":
            {
                Menu menu = new Menu();
                menu.ChooseTable();
                break;
            }

            default:
            {
                Console.WriteLine("Invalid selection. Please select 1, 2, 3, 4 or 5.");
                break;
            }
            }
        }