public Interfaces.IBankResult GetRate(string currencyFrom, DateTime date, string bmxToken = "") { IBankResult r = null; IBank bank = null; switch (currencyFrom) { case "CAD": bank = BankFactory.GetBank(BankFactory.SupportedBanks.BOC); break; case "RUB": bank = BankFactory.GetBank(BankFactory.SupportedBanks.CBR); break; case "UAH": bank = BankFactory.GetBank(BankFactory.SupportedBanks.NBU); break; case "EUR": bank = BankFactory.GetBank(BankFactory.SupportedBanks.ECB); break; case "MXN": bank = BankFactory.GetBank(BankFactory.SupportedBanks.BOMX, bmxToken); break; case "AUD": bank = BankFactory.GetBank(BankFactory.SupportedBanks.RBA); break; case "GBP": bank = BankFactory.GetBank(BankFactory.SupportedBanks.BOE); break; default: break; } Task.Run(async() => { r = await bank.GetRateAsync("USD", date); }).Wait(); var result = new Result { BankName = r.BankName, RateDate = r.RateDate, HomeCurrency = r.HomeCurrency }; result.ExchangeRate = (currencyFrom == "GBP")? decimal.Round(1 / r.ExchangeRate, 4): r.ExchangeRate; return(result); }
public BankResult ExchangeRate(Guid bank, DateTime transactionDate, Guid currency) { // //Available at [Application Address]/0/rest/ExchangeRateWS/ExchangeRate UserConnection userConnection = UserConnection ?? SystemUserConnection; BankFactory.SupportedBanks selectedBank = BankFactory.SupportedBanks.BOC; switch (bank.ToString()) { case "c64cb3d6-3c87-4eb6-88ec-13d03ef5391e": selectedBank = BankFactory.SupportedBanks.BOC; break; case "2cb64ddc-1e80-4a92-a647-843746968206": selectedBank = BankFactory.SupportedBanks.CBR; break; case "82966eac-b7fa-4a5f-b205-f03724c09226": selectedBank = BankFactory.SupportedBanks.NBU; break; case "3444ff4e-7f8f-4695-a0bb-21a3b2c6536a": selectedBank = BankFactory.SupportedBanks.ECB; break; default: selectedBank = BankFactory.SupportedBanks.BOC; break; } IBank cbr = BankFactory.GetBank(selectedBank); string cur = GetCurrencyNameById(userConnection, currency); IBankResult res = cbr.GetRateAsync(cur, transactionDate).Result; return((BankResult)res); }