public void Reload() { myMaxCurrencyTranslationsAgeInDays = -1; Currencies.Clear(); var ctx = myProjectHost.Project.GetAssetsContext(); if (!ctx.Currencies.Any()) { ctx.Currencies.Add(new Currency { Symbol = "EUR", Name = "Euro" }); ctx.Currencies.Add(new Currency { Symbol = "USD", Name = "U.S. Dollar" }); ctx.SaveChanges(); } // first load all currencies so that when loading the translations all currencies are loaded and so a translation // can be initialized completely before setting IsMaterialized = true. // without that we face the problem that IsMaterialized = true is set BEFORE the Target is set. This causes // unwanted Timestamp updates ctx.Currencies.Load(); foreach (var currency in ctx.Currencies.Include(c => c.Translations)) { Currencies.Add(currency); } }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Currencies.Clear(); var items = await repository.GetItemsAsync(1); foreach (var item in items) { Currencies.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public void UpdateCurrencies(List <Currency> currencies) { Currencies.Clear(); currencies.ForEach(currency => { Currencies.Add(currency); }); currenciesGrid.Update(); currenciesGrid.Refresh(); }
private void ClearCurrencies() { foreach (var currency in Currencies) { currency.IsSelectedChanged -= IsSelectedChanged; } Currencies.Clear(); }
internal void sortCurrencies() { List <Currency> tmp = Currencies.OrderBy(Currency => Currency.State).ToList(); Currencies.Clear(); for (int i = tmp.Count - 1; i >= 0; i--) { Currencies.Add(tmp[i]); } }
public void Clear() { Languages.Clear(); Currencies.Clear(); StoreMappings.Clear(); CustomerRoleMappings.Clear(); Manufacturers.Clear(); Categories.Clear(); DeliveryTimes.Clear(); Translations.Clear(); CustomProperties.Clear(); }
private void UpdateCurrencies() { var rootObject = DownloadExchangeRates(Engine); LastUpdate = DateTime.Parse((string)rootObject["date"]); var baseCurrency = (string)rootObject["base"]; var rates = (ScriptObject)rootObject["rates"]; Engine.WriteHighlightLine($"# Using rates defined as of {LastUpdate:yyyy-MM-dd}."); Currencies.Clear(); RegisterBaseCurrency(baseCurrency); foreach (var keyPair in rates) { var currencyName = keyPair.Key; var currencyValue = Engine.ToObject <decimal>(Engine.CurrentSpan, keyPair.Value); RegisterCurrency(currencyName, currencyValue); } // If we have a different base currency from config and it is available, change it immediately if (Engine.Config.TryGetValue(ConfigBaseCurrencyProp, out var configBaseCurrency)) { if (configBaseCurrency is string configBaseCurrencyStr) { if (configBaseCurrencyStr != baseCurrency) { if (rates.ContainsKey(configBaseCurrencyStr)) { RegisterBaseCurrency(configBaseCurrencyStr); } else { Engine.WriteErrorLine($"The config.{ConfigBaseCurrencyProp} = \"{configBaseCurrencyStr}\" does not exist in the defined rates and cannot be used as default."); } } } else { Engine.WriteErrorLine($"Invalid value for config.{ConfigBaseCurrencyProp} = {configBaseCurrency}, Expecting a string instead of {Engine.GetTypeName(configBaseCurrency)}."); } } }
public bool GetCurrenciesInfo() { Currencies.Clear(); return UpdateCurrencies(); }