本文整理汇总了C#中CurrencyModel类的典型用法代码示例。如果您正苦于以下问题:C# CurrencyModel类的具体用法?C# CurrencyModel怎么用?C# CurrencyModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CurrencyModel类属于命名空间,在下文中一共展示了CurrencyModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateLocales
protected void UpdateLocales(Currency currency, CurrencyModel model)
{
foreach (var localized in model.Locales)
{
_localizedEntityService.SaveLocalizedValue(currency,
x => x.Name,
localized.Name,
localized.LanguageId);
}
}
示例2: Create
public ActionResult Create()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageCurrencies))
return AccessDeniedView();
var model = new CurrencyModel();
//locales
AddLocales(_languageService, model.Locales);
//default values
model.Published = true;
model.Rate = 1;
return View(model);
}
示例3: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(CurrencyModel model, Currency currency, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableStores = _storeService
.GetAllStores()
.Select(s => s.ToModel())
.ToList();
if (!excludeProperties)
{
if (currency != null)
{
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(currency);
}
}
}
示例4: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(CurrencyModel model, Currency currency, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
if (!excludeProperties && currency != null)
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(currency).ToList();
var allStores = _storeService.GetAllStores();
foreach (var store in allStores)
{
model.AvailableStores.Add(new SelectListItem
{
Text = store.Name,
Value = store.Id.ToString(),
Selected = model.SelectedStoreIds.Contains(store.Id)
});
}
}
示例5: Edit
public ActionResult Edit(CurrencyModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageCurrencies))
return AccessDeniedView();
var currency = _currencyService.GetCurrencyById(model.Id);
if (currency == null)
//No currency found with the specified id
return RedirectToAction("List");
if (ModelState.IsValid)
{
currency = model.ToEntity(currency);
currency.UpdatedOnUtc = DateTime.UtcNow;
_currencyService.UpdateCurrency(currency);
//locales
UpdateLocales(currency, model);
//Stores
SaveStoreMappings(currency, model);
SuccessNotification(_localizationService.GetResource("Admin.Configuration.Currencies.Updated"));
return continueEditing ? RedirectToAction("Edit", new { id = currency.Id }) : RedirectToAction("List");
}
//If we got this far, something failed, redisplay form
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(currency.CreatedOnUtc, DateTimeKind.Utc);
//Stores
PrepareStoresMappingModel(model, currency, true);
return View(model);
}
示例6: Edit
public ActionResult Edit(CurrencyModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageCurrencies))
return AccessDeniedView();
var currency = _currencyService.GetCurrencyById(model.Id);
if (currency == null)
//No currency found with the specified id
return RedirectToAction("List");
if (ModelState.IsValid)
{
//ensure we have at least one published language
var allCurrencies = _currencyService.GetAllCurrencies();
if (allCurrencies.Count == 1 && allCurrencies[0].Id == currency.Id &&
!model.Published)
{
ErrorNotification("At least one published currency is required.");
return RedirectToAction("Edit", new { id = currency.Id });
}
currency = model.ToEntity(currency);
currency.UpdatedOnUtc = DateTime.UtcNow;
_currencyService.UpdateCurrency(currency);
//locales
UpdateLocales(currency, model);
//Stores
SaveStoreMappings(currency, model);
SuccessNotification(_localizationService.GetResource("Admin.Configuration.Currencies.Updated"));
if (continueEditing)
{
//selected tab
SaveSelectedTabIndex();
return RedirectToAction("Edit", new {id = currency.Id});
}
return RedirectToAction("List");
}
//If we got this far, something failed, redisplay form
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(currency.CreatedOnUtc, DateTimeKind.Utc);
//Stores
PrepareStoresMappingModel(model, currency, true);
return View(model);
}
示例7: CurrencySelector
public ActionResult CurrencySelector()
{
var availableCurrencies = _cacheManager.Get(string.Format(ModelCacheEventConsumer.AVAILABLE_CURRENCIES_MODEL_KEY, _workContext.WorkingLanguage.Id, _storeContext.CurrentStore.Id), () =>
{
var result = _currencyService
.GetAllCurrencies(storeId: _storeContext.CurrentStore.Id)
.Select(x =>
{
//currency char
var currencySymbol = "";
if (!string.IsNullOrEmpty(x.DisplayLocale))
currencySymbol = new RegionInfo(x.DisplayLocale).CurrencySymbol;
else
currencySymbol = x.CurrencyCode;
//model
var currencyModel = new CurrencyModel
{
Id = x.Id,
Name = x.GetLocalized(y => y.Name),
CurrencySymbol = currencySymbol
};
return currencyModel;
})
.ToList();
return result;
});
var model = new CurrencySelectorModel
{
CurrentCurrencyId = _workContext.WorkingCurrency.Id,
AvailableCurrencies = availableCurrencies
};
if (model.AvailableCurrencies.Count == 1)
Content("");
return PartialView(model);
}
示例8: PrepareCurrencyModel
private void PrepareCurrencyModel(CurrencyModel model, Currency currency, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
var allStores = _services.StoreService.GetAllStores();
model.AvailableStores = allStores.Select(s => s.ToModel()).ToList();
if (currency != null)
{
model.PrimaryStoreCurrencyStores = allStores
.Where(x => x.PrimaryStoreCurrencyId == currency.Id)
.Select(x => new SelectListItem
{
Text = x.Name,
Value = Url.Action("Edit", "Store", new { id = x.Id })
})
.ToList();
model.PrimaryExchangeRateCurrencyStores = allStores
.Where(x => x.PrimaryExchangeRateCurrencyId == currency.Id)
.Select(x => new SelectListItem
{
Text = x.Name,
Value = Url.Action("Edit", "Store", new { id = x.Id })
})
.ToList();
}
if (!excludeProperties)
{
model.SelectedStoreIds = (currency == null ? new int[0] : _storeMappingService.GetStoresIdsWithAccess(currency));
}
}
示例9: Edit
public ActionResult Edit(CurrencyModel model, bool continueEditing)
{
if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageCurrencies))
return AccessDeniedView();
var currency = _currencyService.GetCurrencyById(model.Id);
if (currency == null)
return RedirectToAction("List");
if (ModelState.IsValid)
{
currency = model.ToEntity(currency);
if (!IsAttachedToStore(currency, _services.StoreService.GetAllStores(), false))
{
currency.UpdatedOnUtc = DateTime.UtcNow;
_currencyService.UpdateCurrency(currency);
//locales
UpdateLocales(currency, model);
//Stores
_storeMappingService.SaveStoreMappings<Currency>(currency, model.SelectedStoreIds);
NotifySuccess(_services.Localization.GetResource("Admin.Configuration.Currencies.Updated"));
return continueEditing ? RedirectToAction("Edit", new { id = currency.Id }) : RedirectToAction("List");
}
}
//If we got this far, something failed, redisplay form
model.CreatedOn = _dateTimeHelper.ConvertToUserTime(currency.CreatedOnUtc, DateTimeKind.Utc);
//Stores
PrepareCurrencyModel(model, currency, true);
return View(model);
}
示例10: UpdateLocales
protected virtual List<LocalizedProperty> UpdateLocales(Currency currency, CurrencyModel model)
{
List<LocalizedProperty> localized = new List<LocalizedProperty>();
foreach (var local in model.Locales)
{
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "Name",
LocaleValue = local.Name
});
}
return localized;
}
示例11: CurrenciesModel
/// <summary>
/// Initializes a new instance of the <see cref="CurrenciesModel"/> class.
/// </summary>
/// <param name="selectedCurrency">The selected currency.</param>
/// <param name="currencies">The currencies.</param>
public CurrenciesModel(string selectedCurrency, CurrencyModel[] currencies)
{
SelectedCurrency = selectedCurrency;
Currencies = currencies;
}
示例12: ApplicationClientModel
public ApplicationClientModel()
{
Currency = new CurrencyModel();
}
示例13: ApplicationAdminModel
public ApplicationAdminModel()
{
Currency = new CurrencyModel();
}
示例14: ApplicationSenderModel
public ApplicationSenderModel()
{
Currency = new CurrencyModel();
}
示例15: SaveStoreMappings
protected void SaveStoreMappings(Currency currency, CurrencyModel model)
{
var existingStoreMappings = _storeMappingService.GetStoreMappings(currency);
var allStores = _storeService.GetAllStores();
foreach (var store in allStores)
{
if (model.SelectedStoreIds != null && model.SelectedStoreIds.Contains(store.Id))
{
//new role
if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0)
_storeMappingService.InsertStoreMapping(currency, store.Id);
}
else
{
//removed role
var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id);
if (storeMappingToDelete != null)
_storeMappingService.DeleteStoreMapping(storeMappingToDelete);
}
}
}