本文整理汇总了C#中CurrencyModel.ToEntity方法的典型用法代码示例。如果您正苦于以下问题:C# CurrencyModel.ToEntity方法的具体用法?C# CurrencyModel.ToEntity怎么用?C# CurrencyModel.ToEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CurrencyModel
的用法示例。
在下文中一共展示了CurrencyModel.ToEntity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public ActionResult Create(CurrencyModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageCurrencies))
return AccessDeniedView();
if (ModelState.IsValid)
{
var currency = model.ToEntity();
currency.CreatedOnUtc = DateTime.UtcNow;
currency.UpdatedOnUtc = DateTime.UtcNow;
_currencyService.InsertCurrency(currency);
//locales
UpdateLocales(currency, model);
//Stores
SaveStoreMappings(currency, model);
SuccessNotification(_localizationService.GetResource("Admin.Configuration.Currencies.Added"));
return continueEditing ? RedirectToAction("Edit", new { id = currency.Id }) : RedirectToAction("List");
}
//If we got this far, something failed, redisplay form
//Stores
PrepareStoresMappingModel(model, null, true);
return View(model);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}