Class CurrencyService
- Namespace
- Dynamicweb.Ecommerce.International
- Assembly
- Dynamicweb.Ecommerce.dll
Currency service provides operations for working with the currency model
public class CurrencyService : ICacheStorage<string, Currency>, ICacheStorage<string>, ICacheStorage
- Inheritance
-
CurrencyService
- Implements
- Inherited Members
Methods
CleanDefault()
Remove default property from currencies.
public void CleanDefault()
ClearCache()
Resets all keys to the default value for objects stored in the object cache
public void ClearCache()
ClearCache(IEnumerable<string>)
Resets the specified keys to the default value for objects stored in the object cache
public void ClearCache(IEnumerable<string> keys)
Parameters
keys
IEnumerable<string>Keys to reset
ClearCache(string)
Resets the specified key to the default value for objects stored in the object cache
public void ClearCache(string key)
Parameters
key
stringKey to reset
Delete(string)
Deletes an instance with the specified parameters.
public void Delete(string currencyCode)
Parameters
currencyCode
stringThe currency code.
Format(Currency, double)
Formats the specified value according to the currency settings.
public string Format(Currency currency, double value)
Parameters
currency
CurrencyThe currency to use for formatting the value
value
doubleThe value - the price to format to a string.
Returns
- string
The formatted value.
Format(Currency, double, bool)
Formats the specified value according to the currency settings.
public string Format(Currency currency, double value, bool showSymbol)
Parameters
currency
CurrencyThe currency to use for formatting the value
value
doubleThe value - the price to format to a string.
showSymbol
boolif set to
true
includes the currency symbol.
Returns
- string
The formatted value.
FormatCurrency(Currency, double, bool)
Formats the currency using the currency rounding method.
public string FormatCurrency(Currency currency, double value, bool showSymbol)
Parameters
currency
CurrencyThe currency to use for formatting the value
value
doubleThe value to format to a currency.
showSymbol
boolif set to
true
show the currency symbol, i.e. $, £, € or DKK.
Returns
- string
System.String., i.e. $1,000.23 or DKK 1.000,23 or €1.000,23
FormatCurrency(Currency, double, bool, bool)
Formats the currency to a currency string. Rounding is either handled by the currency rounding or to nearest 2 decimals.
public string FormatCurrency(Currency currency, double value, bool showSymbol, bool useCurrencyRounding)
Parameters
currency
CurrencyThe currency to use for formatting the value
value
doubleThe value to format to a currency.
showSymbol
boolif set to
true
show the currency symbol, i.e. $, £, € or DKK.useCurrencyRounding
boolif set to
true
the rounding specified on the currency will be used for rounding, otherwise the value is rounded to 2 decimals.
Returns
- string
System.String., i.e. $1,000.23 or DKK 1.000,23 or €1.000,23
GetAllCurrencies()
Gets all currencies.
public IEnumerable<Currency> GetAllCurrencies()
Returns
- IEnumerable<Currency>
A collection of the Currency.
GetCurrency(string)
Gets a currency by currency code.
public Currency GetCurrency(string currencyCode)
Parameters
currencyCode
stringThe currency code.
Returns
GetCurrencyOrDefault(string)
Gets the currency by currency code. Returns the default currency if the selected currency is not found.
public Currency GetCurrencyOrDefault(string currencyCode)
Parameters
currencyCode
stringCurrency code
Returns
GetDefaultCurrency()
Gets the default currency.
public Currency GetDefaultCurrency()
Returns
GetNumberFormatInfo(Currency)
Returns number format info related to specified currency. If currency's culture info is not found, get number format info from execution context.
public NumberFormatInfo GetNumberFormatInfo(Currency currency)
Parameters
currency
CurrencyThe currency to provide number format info.
Returns
- NumberFormatInfo
The NumberFormatInfo object.
GetOrCreateCurrency(string, string, double, string)
Gets existed currency. If currency is not found, creates the custom currency based on currency data.
public Currency GetOrCreateCurrency(string currencyCode, string currencyName, double currencyRate, string languageId)
Parameters
currencyCode
stringCurrency code
currencyName
stringCurrency name
currencyRate
doubleCurrency rate
languageId
stringLanguage id
Returns
- Currency
Returns the currency by currency code. If currency code is empty, returns null. If currency code is set, but nothing is found, returns custom currency.
Round(Currency, double)
Rounds the value.
public double Round(Currency currency, double value)
Parameters
Returns
- double
The rounded value.
Save(Currency)
Saves a currency instance
public void Save(Currency currency)
Parameters
currency
CurrencyThe currency.
UpdateCurrencyCode(string, string)
Update currency and its relations with a new Code.
public void UpdateCurrencyCode(string oldCode, string newCode)