Table of Contents

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 string

Key to reset

Delete(string)

Deletes an instance with the specified parameters.

public void Delete(string currencyCode)

Parameters

currencyCode string

The currency code.

Format(Currency, double)

Formats the specified value according to the currency settings.

public string Format(Currency currency, double value)

Parameters

currency Currency

The currency to use for formatting the value

value double

The 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 Currency

The currency to use for formatting the value

value double

The value - the price to format to a string.

showSymbol bool

if 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 Currency

The currency to use for formatting the value

value double

The value to format to a currency.

showSymbol bool

if 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 Currency

The currency to use for formatting the value

value double

The value to format to a currency.

showSymbol bool

if set to true show the currency symbol, i.e. $, £, € or DKK.

useCurrencyRounding bool

if 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 string

The currency code.

Returns

Currency

An instance of Currency, if found, otherwise null.

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 string

Currency code

Returns

Currency

GetDefaultCurrency()

Gets the default currency.

public Currency GetDefaultCurrency()

Returns

Currency

A currency Currency.

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 Currency

The 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 string

Currency code

currencyName string

Currency name

currencyRate double

Currency rate

languageId string

Language 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

currency Currency
value double

The value.

Returns

double

The rounded value.

Save(Currency)

Saves a currency instance

public void Save(Currency currency)

Parameters

currency Currency

The currency.

UpdateCurrencyCode(string, string)

Update currency and its relations with a new Code.

public void UpdateCurrencyCode(string oldCode, string newCode)

Parameters

oldCode string

The old code.

newCode string

The new code.

To top