Exemple #1
0
        internal static bool Validate(string userInput)
        {
            if (string.IsNullOrWhiteSpace(userInput))
            {
                StandardMessages.DisplayValidationError(userInput);
                return(false);
            }

            if (!string.IsNullOrWhiteSpace(userInput))
            {
                int convertedInput = Convert.ToInt32(userInput);

                if (convertedInput > 2)
                {
                    StandardMessages.DisplayValidationError(userInput);
                    return(false);
                }
            }

            if (userInput.Equals("1"))
            {
                StandardServices services = new StandardServices();

                Task displayDataTask = services.DisplayData();

                // Wait for all tasks running to complete their execution
                Task.WaitAll(displayDataTask);

                return(true);
            }

            if (userInput.Equals("2"))
            {
                StandardServices services = new StandardServices();

                Task downloadDataTask = services.DownloadData();

                // Wait for all tasks running to complete their execution
                Task.WaitAll(downloadDataTask);

                return(true);
            }

            return(true);
        }
        static void Main(string[] args)
        {
            StandardMessages.WelcomeMessage();

            ApiHelper.InitializeClient();

            string userInput = UserInputDataCapture.Capture();

            bool iValidInput = UserInputDataValidator.Validate(userInput);

            if (iValidInput == false)
            {
                StandardMessages.EndApplication();
                return;
            }

            StandardMessages.EndApplication();
        }