public void SaveRate(DateTime pDate, double pRate, Currency pCurrency) { if (pDate == DateTime.MinValue) { throw new OpenCbsExchangeRateException(OpenCbsExchangeRateExceptionEnum.DateIsNull); } if (pRate == 0) { throw new OpenCbsExchangeRateException(OpenCbsExchangeRateExceptionEnum.RateIsEmpty); } if (pCurrency == null) { throw new OpenCbsExchangeRateException(OpenCbsExchangeRateExceptionEnum.RateIsEmpty); } if (SelectExchangeRate(pDate, pCurrency) != null) { _rateManager.Update(pDate, pRate, pCurrency); } else { _rateManager.Add(pDate, pRate, pCurrency); } }
public void UpdateExchangeRate() { ExchangeRateManager exchangeRateManager = (ExchangeRateManager)container["ExchangeRateManager"]; ExchangeRate selectedExchangeRate = exchangeRateManager.Select(new DateTime(2008, 8, 8), new Currency { Id = 2 }); Assert.AreEqual(2, selectedExchangeRate.Rate); exchangeRateManager.Update(new DateTime(2008, 8, 8), 12, new Currency { Id = 2 }); ExchangeRate updatedExchangeRate = exchangeRateManager.Select(new DateTime(2008, 8, 8), new Currency { Id = 2 }); Assert.AreEqual(12, updatedExchangeRate.Rate); }