Interface ICurrencyService
Used to get detailed information about currencies and some helper functions.
Namespace: DirectScale.Disco.Extension.Services
Assembly: DirectScale.Disco.Extension.Abstractions.dll
Syntax
public interface ICurrencyService
Remarks
Currencies are configured from the Currency admin page. CurrencyCode will usually refer to the standard 3 digit ISO-4217 currency code. See Currency, GetCurrency(String), and GetCurrencyCode(String) for more details.
Methods
Convert(Decimal, String, String)
Converts amount
from fromCurrency
to toCurrency
using their ExchangeRates.
Declaration
Task<Decimal> Convert(Decimal amount, string fromCurrency, string toCurrency)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | amount | Amount to convert. |
System.String | fromCurrency | Current currency of |
System.String | toCurrency | Desired currency of |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Decimal> |
|
GetBaseCurrencyCode()
Returns "usd", but should probably return "USD".
Declaration
Task<string> GetBaseCurrencyCode()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> |
GetCurrencies()
Returns all currencies.
Declaration
Task<Currency[]> GetCurrencies()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Currency[]> |
GetCurrency(String)
Gets the currency details from the currency code.
Declaration
Task<Currency> GetCurrency(string currencyCode)
Parameters
Type | Name | Description |
---|---|---|
System.String | currencyCode | currency code. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Currency> | Currency details. |
See Also
GetCurrencyCode(String)
Gets the ISO-4217 3 digit currency code from the ISO 3166-1 alpha-2 countryCode
.
Declaration
Task<string> GetCurrencyCode(string countryCode)
Parameters
Type | Name | Description |
---|---|---|
System.String | countryCode | Lower-case 2 digit country code. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | Upper-case 3 digit currency code. |
Examples
countryCode: "us" "USD" countryCode: "jp" "JPY"
MaskAmount(Double, String)
Gives the formatted string representation rounding to the correct number of DecimalLength places. Does not mask anything.
Declaration
Task<string> MaskAmount(double amount, string currencyCode)
Parameters
Type | Name | Description |
---|---|---|
System.Double | amount | The amount of currency to format. |
System.String | currencyCode | The specific currency to display. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | A string representation of |
Examples
amount: 123.4567, currencyCode: "USD" "123.46" amount: 123.4567, currencyCode: "JPY" "123" amount: 123.4567, currencyCode: "JOD" "123.457"
See Also
Round(Decimal, String)
Rounds amount
to the correct number of DecimalLength places for currencyCode
.
Declaration
Task<Decimal> Round(Decimal amount, string currencyCode)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | amount | |
System.String | currencyCode |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Decimal> | Rounded value as a decimal. |