Class CurrencyService
Inheritance
Implements
Namespace: DirectScale.Disco.Extension.Services
Assembly: DirectScale.Disco.Extension.Abstractions.dll
Syntax
public class CurrencyService : Object, ICurrencyService
Constructors
CurrencyService(IApiService)
Declaration
public CurrencyService(IApiService apiService)
Parameters
Type | Name | Description |
---|---|---|
IApiService | apiService |
Methods
Convert(Decimal, String, String)
Converts amount
from fromCurrency
to toCurrency
using their ExchangeRates.
Declaration
public 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
public Task<string> GetBaseCurrencyCode()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> |
GetCurrencies()
Returns all currencies.
Declaration
public Task<Currency[]> GetCurrencies()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Currency[]> |
GetCurrency(String)
Gets the currency details from the currency code.
Declaration
public 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
public 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
public 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
public 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. |