Exemplo n.º 1
0
        /// <summary>
        /// Starts the TflClientService and executes the application logic, making sure the correct parameters are passed.
        /// </summary>
        /// <param name="service"></param>
        /// <param name="services"></param>
        /// <returns></returns>
        static async Task Execute(TflClientService service, ServiceCollection services)
        {
            Console.WriteLine("Hello, please type below the road you want to find information:");
            daRoad = Console.ReadLine();
            if (!String.IsNullOrEmpty(daRoad))
            {
                try
                {
                    Console.WriteLine(_validator.ValidateRequest(await service.InitializeClient(daRoad, services), daRoad));
                    Console.WriteLine((int)ExitCode.Success);
                    return;
                }
                catch (InvalidRoadException e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine((int)ExitCode.InvalidRequest);
                    return;
                }
            }

            Console.WriteLine(new NullRoadIdException("").Message);
            Console.WriteLine((int)ExitCode.InvalidRequest);
            return;
        }