Beispiel #1
0
        private void OnExecute(CommandLineApplication app)
        {
            if (string.IsNullOrEmpty(CurrencyPair))
            {
                app.ShowHelp();
            }

            var currencies       = CurrencyPair.Split('/');
            var baseCurrencyISO  = currencies[0];
            var quoteCurrencyISO = currencies[1];

            try
            {
                var exchanger = new RateExchanger(new HardCodedCurrencyPairRepository());
                var result    = exchanger.Exchage(baseCurrencyISO, quoteCurrencyISO, (decimal)Amount);
                Console.WriteLine(result.Amount);
            }
            catch (RateNotFoundException)
            {
                Console.WriteLine("Rate not found.");
            }
            catch (Exception)
            {
                Console.WriteLine("Unknown error.");
            }
        }