public async Task <bool> refreshCurrenciesRateByDefault(CurrencyModel obj) { bool result = false; var defaultCurrency = obj;// CurrenciesList.Where(x=>x.IsDefault).SingleOrDefault(); if (defaultCurrency != null && defaultCurrency.Currency.ID != 0) { foreach (CurrencyModel currencyModel in CurrenciesList) { currencyModel.Currency.Date = DateTime.Now; currencyModel.Currency.Rate = ExchangeRateFromAPI(defaultCurrency.TxtCurrencyCode, currencyModel.TxtCurrencyCode); } var savedCurrencies = await Bl.BlOrder.UpdateCurrencyAsync(CurrenciesList.Select(x => x.Currency).ToList()); if (savedCurrencies.Count > 0) { result = true; CurrenciesList = new List <CurrencyModel>(savedCurrencies.Select(x => new CurrencyModel { Currency = x }).ToList()); } } return(result); }
public static IEnumerable <SelectListItem> CurrencyList() { return(CurrenciesList.Select(c => new SelectListItem() { Value = c.ISOCurrencySymbol, Text = $"{c.ISOCurrencySymbol} – {c.CurrencySymbol}", //Selected = c.ISOCurrencySymbol == new RegionInfo(CultureInfo.CurrentCulture.LCID).ISOCurrencySymbol }) .OrderBy(s => s.Text)); }