---
title: Currencies and exchange rates
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

List of examples:

## Currencies

### Creating a new currency

```csharp

// Creates a new currency object
CurrencyInfo newCurrency = new CurrencyInfo();

// Sets the currency properties
newCurrency.CurrencyDisplayName = "New currency";
newCurrency.CurrencyName = "NewCurrency";
newCurrency.CurrencyCode = "NC";
newCurrency.CurrencySiteID = SiteContext.CurrentSiteID;
newCurrency.CurrencyEnabled = true;
newCurrency.CurrencyFormatString = "{0:F} NC";
newCurrency.CurrencyIsMain = false;

// Saves the currency to the database
CurrencyInfo.Provider.Set(newCurrency);

```

[> Back to list of examples](#toc)

### Updating a currency

```csharp

// Gets the currency
CurrencyInfo updateCurrency = CurrencyInfo.Provider.Get("NewCurrency", SiteContext.CurrentSiteID);
if (updateCurrency != null)
{
    // Updates the currency properties
    updateCurrency.CurrencyDisplayName = updateCurrency.CurrencyDisplayName.ToLowerCSafe();

    // Saves the changes to the database
    CurrencyInfo.Provider.Set(updateCurrency);
}

```

[> Back to list of examples](#toc)

### Updating multiple currencies

```csharp

// Gets all currencies whose code name starts with 'NewCurrency'
var currencies = CurrencyInfo.Provider.Get().WhereStartsWith("CurrencyName", "NewCurrency");

// Loops through the currency objects
foreach (CurrencyInfo modifyCurrency in currencies)
{
    // Updates the currency properties
    modifyCurrency.CurrencyDisplayName = modifyCurrency.CurrencyDisplayName.ToUpperCSafe();

    // Saves the changes to the database
    CurrencyInfo.Provider.Set(modifyCurrency);
}

```

[> Back to list of examples](#toc)

### Deleting a currency

```csharp

// Gets the currency
CurrencyInfo deleteCurrency = CurrencyInfo.Provider.Get("NewCurrency", SiteContext.CurrentSiteID);
if (deleteCurrency != null)
{
    // Deletes the currency
    CurrencyInfo.Provider.Delete(deleteCurrency);
}

```

[> Back to list of examples](#toc)

## Exchange tables

### Creating an exchange table

```csharp

// Creates a new exchange table object
ExchangeTableInfo newTable = new ExchangeTableInfo();

// Sets the exchange table properties
newTable.ExchangeTableDisplayName = "New table";
newTable.ExchangeTableSiteID = SiteContext.CurrentSiteID;
newTable.ExchangeTableValidFrom = DateTime.Now;
newTable.ExchangeTableValidTo = DateTime.Now;

// Saves the exchange table to the database
ExchangeTableInfo.Provider.Set(newTable);

```

[> Back to list of examples](#toc)

### Updating an exchange table

```csharp

// Gets the exchange table
ExchangeTableInfo updateTable = ExchangeTableInfoProvider.GetExchangeTableInfo("New table", SiteContext.CurrentSiteName);
if (updateTable != null)
{
    // Sets the desired time
    TimeSpan time = TimeSpan.FromDays(7);

    // Updates the time validity properties
    updateTable.ExchangeTableValidFrom = updateTable.ExchangeTableValidFrom.Add(time);
    updateTable.ExchangeTableValidTo = updateTable.ExchangeTableValidTo.Add(time);

    // Saves the changes to the database
    ExchangeTableInfo.Provider.Set(updateTable);
}

```

[> Back to list of examples](#toc)

### Updating multiple exchange tables

```csharp

// Gets all exchange tables assigned to the current site whose display name starts with 'New table'
var tables = ExchangeTableInfo.Provider.Get()
                                        .OnSite(SiteContext.CurrentSiteID)
                                        .WhereStartsWith("ExchangeTableDisplayName", "New table");

// Prepares a 14 day time span for the exchange table validity
TimeSpan time = TimeSpan.FromDays(14);

// Loops through the exchange tables
foreach (ExchangeTableInfo modifyTable in tables)
{
    // Updates the time validity properties
    modifyTable.ExchangeTableValidFrom = modifyTable.ExchangeTableValidFrom.Add(time);
    modifyTable.ExchangeTableValidTo = modifyTable.ExchangeTableValidTo.Add(time);

    // Saves the changes to the database
    ExchangeTableInfo.Provider.Set(modifyTable);
}

```

[> Back to list of examples](#toc)

### Deleting an exchange table

```csharp

// Gets the exchange table
ExchangeTableInfo deleteTable = ExchangeTableInfoProvider.GetExchangeTableInfo("New table", SiteContext.CurrentSiteName);

if (deleteTable != null)
{
    // Deletes the exchange table
    ExchangeTableInfo.Provider.Delete(deleteTable);
}

```

[> Back to list of examples](#toc)
