public IActionResult Get(string code)
 {
     try
     {
         return(Ok(_exchangeService.GetExchange(code)));
     }
     catch (NotSupportedCurrencyException)
     {
         return(BadRequest());
     }
     catch (Exception)
     {
         return(StatusCode(500));
     }
 }
Example #2
0
        private decimal CalcPurchaseAmount(Transaction transaction)
        {
            var currencyExchange = _exchangeService.GetExchange(transaction.CurrencyCode);

            return(Math.Round(transaction.Amount / currencyExchange.BuyingRate, 2));
        }