public async Task <double> BuyTransfers(double amount, CurrencyCodes currencyCode)
        {
            try
            {
                string partition = currencyCode.ToString();
                string row       = DateTime.Now.ToString("yyyy-MM-dd");

                var exchange = await _azureTableStorage.RetrieveExchangeRateUsingPointQueryAsync(partition, row);

                var exchangerate = new { Multiplier = exchange.Multiplier, BuyTransfers = exchange.BuyTransfers };

                if (exchangerate == null)
                {
                    _log.LogError("Unable to get latest exchangerate for: {0} ", currencyCode.ToString());
                    throw new ArgumentException("Could not get the exchangerate for this currency");
                }

                return(convert(exchangerate.Multiplier, amount, Convert.ToDouble(exchangerate.BuyTransfers)));
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message, ex);
                throw;
            }
        }
        protected virtual void Initialize(CurrencyCodes targetCurrencyCode)
        {
            // initialize currency
            _currencyExchangerRates.Add(CurrencyCodes.EUR, 1);
            _currencyExchangerRates.Add(CurrencyCodes.GBP, new decimal(0.84));
            _currencyExchangerRates.Add(CurrencyCodes.USD, new decimal(1.40));

            if (!_currencyExchangerRates.ContainsKey(targetCurrencyCode))
                throw new NotSupportedException(string.Format("Currency code {0} in payload not supported or not ISO 4217 conform. Please chose one of following codes: {0}.", targetCurrencyCode.ToString(), _currencyExchangerRates.Keys.ToString()));

            this.Code = targetCurrencyCode.ToString();
            this.ExchangeRate = _currencyExchangerRates[targetCurrencyCode];
        }
        public override string ToString()
        {
            switch (Currency)
            {
            case CurrencyCodes.USD:
                return($"{Timestamp:d} {Amount} {Currency.ToString().ToLower()} {Comment}");

            case CurrencyCodes.BYR:
                return($"{Timestamp:d} {Amount:#,0} {Currency.ToString().ToLower()} ({AmountInUsdString}) {Comment}");

            default:
                return($"{Timestamp:d} {Amount:#,0.00} {Currency.ToString().ToLower()} ({AmountInUsdString}) {Comment}");
            }
        }
        private static string ProcentPredictionRepresentation(decimal amount, CurrencyCodes currency, decimal rate, Period period)
        {
            if (amount == 0)
            {
                return(currency == CurrencyCodes.USD ? "0 usd" : $"0 {currency.ToString().ToLower()}    ($0)");
            }

            if (currency == CurrencyCodes.USD)
            {
                return($"(за период {period.ToStringOnlyDates()})  {amount:#,0.00} usd");
            }
            return(rate == 0 ? "не задан курс" :
                   String.Format("(за период {4})  {0:#,0} {1}   (по курсу {2} = ${3:#,0})",
                                 amount, currency.ToString().ToLower(), (int)rate, amount / rate, period.ToStringOnlyDates()));
        }
        protected virtual void Initialize(CurrencyCodes targetCurrencyCode)
        {
            // initialize currency
            _currencyExchangerRates.Add(CurrencyCodes.EUR, 1);
            _currencyExchangerRates.Add(CurrencyCodes.GBP, new decimal(0.84));
            _currencyExchangerRates.Add(CurrencyCodes.USD, new decimal(1.40));

            if (!_currencyExchangerRates.ContainsKey(targetCurrencyCode))
            {
                throw new NotSupportedException(string.Format("Currency code {0} in payload not supported or not ISO 4217 conform. Please chose one of following codes: {0}.", targetCurrencyCode.ToString(), _currencyExchangerRates.Keys.ToString()));
            }

            this.Code         = targetCurrencyCode.ToString();
            this.ExchangeRate = _currencyExchangerRates[targetCurrencyCode];
        }
Exemple #6
0
        private static string GetDefaultPriceListName(CurrencyCodes currency)
        {
            var retVal = "Default" + currency.ToString();

            return(retVal);
        }
		private static string GetDefaultPriceListName(CurrencyCodes currency)
		{
			var retVal = "Default" + currency.ToString();
			return retVal;
		}
Exemple #8
0
        } // !FromString()

        public static string EnumToString(this CurrencyCodes c)
        {
            return(c.ToString("g"));
        } // !ToString()