/// <summary> /// Gets the exchange rate between company currency and channel currency. /// </summary> /// <param name="context">The request context.</param> /// <returns>The exchange rate between company and channel currency.</returns> private static decimal GetExchangeRate(RequestContext context) { // Default exchange rate value if the company currency and the channel currency are the same. decimal exchangeRate = 1.00M; if (!context.GetChannelConfiguration().Currency.Equals(context.GetChannelConfiguration().CompanyCurrency, StringComparison.OrdinalIgnoreCase)) { var currencyRequest = new GetExchangeRateServiceRequest(context.GetChannelConfiguration().CompanyCurrency, context.GetChannelConfiguration().Currency); var currencyResponse = context.Execute <GetExchangeRateServiceResponse>(currencyRequest); exchangeRate = currencyResponse.ExchangeRate; } return(exchangeRate); }
/// <summary> /// Internal wrapper for GetExchangeRate. This derives the parameters from a currency request instance. /// </summary> /// <param name="request">Currency request with retail runtime and currencies specified.</param> /// <returns>The unrounded exchange rate.</returns> private static GetExchangeRateServiceResponse GetExchangeRate(GetExchangeRateServiceRequest request) { return(GetExchangeRate(request.RequestContext, request.FromCurrencyCode, request.ToCurrencyCode)); }