Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ServiceInteraction serviceInteraction = new ServiceInteraction();

            Console.WriteLine("Welcome! Please choose an option to fetch information about e-prescriptions.");

            do
            {
                Console.WriteLine("Menu: \n" +
                                  "1: Get all interchanges \n" +
                                  "2: Get all test interchanges \n" +
                                  "3: Filter interchanges by ID \n" +
                                  "4: Filter interchanges by node \n" +
                                  "5: Filter interchanges by node and ID \n" +
                                  "6: Filter interchanges by node value");

                int input = Int32.Parse(Console.ReadLine());

                switch (input)
                {
                case 1:
                    serviceInteraction.GetAll();
                    break;

                case 2:
                    serviceInteraction.GetTestData();
                    break;

                case 3:
                    Console.WriteLine("Please give us an ID");
                    int inputID = Int32.Parse(Console.ReadLine());
                    serviceInteraction.GetFilteredByID(inputID);
                    break;

                case 4:
                    Console.WriteLine("Please give us a node name");
                    string inputNodeName = Console.ReadLine();
                    serviceInteraction.GetFilteredByNode(inputNodeName);
                    break;

                case 5:
                    Console.WriteLine("Please give us an ID");
                    inputID = Int32.Parse(Console.ReadLine());

                    Console.WriteLine("Please give us a node name");
                    inputNodeName = Console.ReadLine();
                    serviceInteraction.GetFilteredByIDAndNode(inputID, inputNodeName);
                    break;

                case 6:
                    Console.WriteLine("Please give us a node name");
                    inputNodeName = Console.ReadLine();

                    Console.WriteLine("Please give us a node value");
                    string inputNodeValue = Console.ReadLine();
                    serviceInteraction.GetFilteredByNodeValue(inputNodeName, inputNodeValue);
                    break;

                default:
                    break;
                }

                Console.Clear();
                PrintXML(serviceInteraction.Result);
                Console.ReadLine();
            } while (true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method handles the menu input and the switch statment picks the choosen option and performs the action.
        /// </summary>
        /// <returns>A bool that is true if the user should get the option to pretty print the XML</returns>
        private bool HandleMenuInput()
        {
            int  input = Int32.Parse(Console.ReadLine());
            bool optionToPrintPrettyXML = false;

            switch (input)
            {
            case 1:
                serviceInteraction.GetAll();
                optionToPrintPrettyXML = true;
                break;

            case 2:
                serviceInteraction.GetTestData();
                optionToPrintPrettyXML = true;
                break;

            case 3:
                Console.WriteLine("Please give us an ID");
                int inputID = Int32.Parse(Console.ReadLine());
                serviceInteraction.GetFilteredByID(inputID);
                optionToPrintPrettyXML = true;
                break;

            case 4:
                Console.WriteLine("Please give us a node name");
                string inputNodeName = Console.ReadLine();
                serviceInteraction.GetFilteredByNode(inputNodeName);
                break;

            case 5:
                Console.WriteLine("Please give us an ID");
                inputID = Int32.Parse(Console.ReadLine());

                Console.WriteLine("Please give us a node name");
                inputNodeName = Console.ReadLine();
                serviceInteraction.GetFilteredByIDAndNode(inputID, inputNodeName);
                break;

            case 6:
                Console.WriteLine("Please give us a node name");
                inputNodeName = Console.ReadLine();

                Console.WriteLine("Please give us a node value");
                string inputNodeValue = Console.ReadLine();
                serviceInteraction.GetFilteredByNodeValue(inputNodeName, inputNodeValue);
                optionToPrintPrettyXML = true;
                break;

            case 7:
                optionToPrintPrettyXML = true;
                break;

            case 8:
                runProgram = false;
                break;

            default:
                runProgram = false;
                break;
            }
            return(optionToPrintPrettyXML);
        }