Search Results for

    Show / Hide Table of Contents

    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 amount.

    System.String toCurrency

    Desired currency of amount.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Decimal>

    amount modified by ExchangeRates as a double.

    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
    Currency

    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 amount with correct number of rounded decimal places. No currency symbols.

    Examples

    amount: 123.4567, currencyCode: "USD" "123.46" amount: 123.4567, currencyCode: "JPY" "123" amount: 123.4567, currencyCode: "JOD" "123.457"

    See Also
    DecimalLength

    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.

    See Also
    MaskAmount(Double, String)

    See Also

    Currency
    In This Article
    Back to top Copyright © 2022 DirectScale
    Generated by DocFX