Example #1
0
        public ExchangeRate FindLatestExchangeRate(DateTime pDate,Currency pCurrency)
        {
            ExchangeRate exchangeRate = null;
             Currency pivot = new CurrencyServices(_user).GetPivot();
            if (!pivot.Equals(pCurrency))
            {
                if (new CurrencyServices(_user).FindAllCurrencies().Count > 1)
                {
                    double rate = _exchangeRateServices.GetMostRecentlyRate(pDate,pCurrency);

                    exchangeRate = new ExchangeRate
                                       {
                                           Currency = pCurrency,
                                           Date = pDate,
                                           Rate = rate
                                       };
                }
            }
            else
            {
                exchangeRate = new ExchangeRate
                {
                    Currency = pCurrency,
                    Date = pDate,
                    Rate = 1
                };
            }
            return exchangeRate;
        }
Example #2
0
        public ExchangeRate FindExchangeRate(DateTime pDate, Currency pCurrency)
        {
            ExchangeRate exchangeRate = null;
            Currency pivot = new CurrencyServices(_user).GetPivot();

            if (!pivot.Equals(pCurrency))
            {
                if (new CurrencyServices(_user).FindAllCurrencies().Count > 1)
                {
                    exchangeRate = _exchangeRateServices.SelectExchangeRate(pDate.Date, pCurrency);
                    if (exchangeRate == null)
                        throw new OpenCbsExchangeRateException(OpenCbsExchangeRateExceptionEnum.ExchangeRateIsNull);
                }
            }
            else
            {
                exchangeRate = new ExchangeRate
                                   {
                                       Currency = pCurrency,
                                       Date = pDate,
                                       Rate = 1
                                   };
            }
            return exchangeRate;
        }