本文整理汇总了C#中CheckoutAttributeModel类的典型用法代码示例。如果您正苦于以下问题:C# CheckoutAttributeModel类的具体用法?C# CheckoutAttributeModel怎么用?C# CheckoutAttributeModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CheckoutAttributeModel类属于命名空间,在下文中一共展示了CheckoutAttributeModel类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
//create
public ActionResult Create()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
return AccessDeniedView();
var model = new CheckoutAttributeModel();
//locales
AddLocales(_languageService, model.Locales);
PrepareCheckoutAttributeModel(model, null, true);
return View(model);
}
开发者ID:emilianionascu,项目名称:NopCommerce,代码行数:12,代码来源:CheckoutAttributeController.cs
示例2: UpdateAttributeLocales
protected virtual void UpdateAttributeLocales(CheckoutAttribute checkoutAttribute, CheckoutAttributeModel model)
{
foreach (var localized in model.Locales)
{
_localizedEntityService.SaveLocalizedValue(checkoutAttribute,
x => x.Name,
localized.Name,
localized.LanguageId);
_localizedEntityService.SaveLocalizedValue(checkoutAttribute,
x => x.TextPrompt,
localized.TextPrompt,
localized.LanguageId);
}
}
开发者ID:jasonholloway,项目名称:brigita,代码行数:15,代码来源:CheckoutAttributeController.cs
示例3: Edit
public ActionResult Edit(CheckoutAttributeModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
return AccessDeniedView();
var checkoutAttribute = _checkoutAttributeService.GetCheckoutAttributeById(model.Id);
if (checkoutAttribute == null)
//No checkout attribute found with the specified id
return RedirectToAction("List");
if (ModelState.IsValid)
{
checkoutAttribute = model.ToEntity(checkoutAttribute);
_checkoutAttributeService.UpdateCheckoutAttribute(checkoutAttribute);
//locales
UpdateAttributeLocales(checkoutAttribute, model);
//Stores
SaveStoreMappings(checkoutAttribute, model);
//activity log
_customerActivityService.InsertActivity("EditCheckoutAttribute", _localizationService.GetResource("ActivityLog.EditCheckoutAttribute"), checkoutAttribute.Name);
SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.CheckoutAttributes.Updated"));
if (continueEditing)
{
//selected tab
SaveSelectedTabIndex();
return RedirectToAction("Edit", new {id = checkoutAttribute.ID});
}
return RedirectToAction("List");
}
//If we got this far, something failed, redisplay form
//tax categories
PrepareTaxCategories(model, checkoutAttribute, true);
//Stores
PrepareStoresMappingModel(model, checkoutAttribute, true);
return View(model);
}
开发者ID:jasonholloway,项目名称:brigita,代码行数:42,代码来源:CheckoutAttributeController.cs
示例4: Create
//create
public ActionResult Create()
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
return AccessDeniedView();
var model = new CheckoutAttributeModel();
//locales
AddLocales(_languageService, model.Locales);
//tax categories
PrepareTaxCategories(model, null, true);
//Stores
PrepareStoresMappingModel(model, null, false);
return View(model);
}
开发者ID:jasonholloway,项目名称:brigita,代码行数:15,代码来源:CheckoutAttributeController.cs
示例5: SaveStoreMappings
protected virtual void SaveStoreMappings(CheckoutAttribute checkoutAttribute, CheckoutAttributeModel model)
{
var existingStoreMappings = _storeMappingService.GetStoreMappings(checkoutAttribute);
var allStores = _storeService.GetAllStores();
foreach (var store in allStores)
{
if (model.SelectedStoreIds != null && model.SelectedStoreIds.Contains(store.ID))
{
//new store
if (existingStoreMappings.Count(sm => sm.StoreId == store.ID) == 0)
_storeMappingService.InsertStoreMapping(checkoutAttribute, store.ID);
}
else
{
//remove store
var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.ID);
if (storeMappingToDelete != null)
_storeMappingService.DeleteStoreMapping(storeMappingToDelete);
}
}
}
开发者ID:jasonholloway,项目名称:brigita,代码行数:21,代码来源:CheckoutAttributeController.cs
示例6: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(CheckoutAttributeModel model, CheckoutAttribute checkoutAttribute, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableStores = _storeService
.GetAllStores()
.Select(s => s.ToModel())
.ToList();
if (!excludeProperties)
{
if (checkoutAttribute != null)
{
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(checkoutAttribute);
}
}
}
开发者ID:jasonholloway,项目名称:brigita,代码行数:17,代码来源:CheckoutAttributeController.cs
示例7: PrepareTaxCategories
protected virtual void PrepareTaxCategories(CheckoutAttributeModel model, CheckoutAttribute checkoutAttribute, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
//tax categories
var taxCategories = _taxCategoryService.GetAllTaxCategories();
model.AvailableTaxCategories.Add(new SelectListItem { Text = "---", Value = "0" });
foreach (var tc in taxCategories)
model.AvailableTaxCategories.Add(new SelectListItem { Text = tc.Name, Value = tc.ID.ToString(), Selected = checkoutAttribute != null && !excludeProperties && tc.ID == checkoutAttribute.TaxCategoryId });
}
开发者ID:jasonholloway,项目名称:brigita,代码行数:11,代码来源:CheckoutAttributeController.cs
示例8: PrepareAclModel
protected virtual void PrepareAclModel(CheckoutAttributeModel model, CheckoutAttribute checkoutAttribute, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
model.AvailableCustomerRoles = _customerService
.GetAllCustomerRoles(true)
.Select(cr => cr.ToModel())
.ToList();
if (!excludeProperties)
{
if (checkoutAttribute != null)
{
model.SelectedCustomerRoleIds = checkoutAttribute.CustomerRoles.ToArray();
}
}
}
开发者ID:freemsly,项目名称:grandnode,代码行数:17,代码来源:CheckoutAttributeController.cs
示例9: UpdateAttributeLocales
protected virtual List<LocalizedProperty> UpdateAttributeLocales(CheckoutAttribute checkoutAttribute, CheckoutAttributeModel model)
{
List<LocalizedProperty> localized = new List<LocalizedProperty>();
foreach (var local in model.Locales)
{
if (!(String.IsNullOrEmpty(local.Name)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "Name",
LocaleValue = local.Name,
_id = ObjectId.GenerateNewId().ToString(),
Id = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1,
});
if (!(String.IsNullOrEmpty(local.TextPrompt)))
localized.Add(new LocalizedProperty()
{
LanguageId = local.LanguageId,
LocaleKey = "TextPrompt",
LocaleValue = local.TextPrompt,
_id = ObjectId.GenerateNewId().ToString(),
Id = localized.Count > 0 ? localized.Max(x => x.Id) + 1 : 1,
});
}
return localized;
}
开发者ID:freemsly,项目名称:grandnode,代码行数:30,代码来源:CheckoutAttributeController.cs
示例10: Create
public ActionResult Create(CheckoutAttributeModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
return AccessDeniedView();
if (ModelState.IsValid)
{
var checkoutAttribute = model.ToEntity();
checkoutAttribute.CustomerRoles = model.SelectedCustomerRoleIds != null ? model.SelectedCustomerRoleIds.ToList() : new List<int>();
checkoutAttribute.Locales = UpdateAttributeLocales(checkoutAttribute, model);
checkoutAttribute.Stores = model.SelectedStoreIds != null ? model.SelectedStoreIds.ToList() : new List<int>();
_checkoutAttributeService.InsertCheckoutAttribute(checkoutAttribute);
//activity log
_customerActivityService.InsertActivity("AddNewCheckoutAttribute", checkoutAttribute.Id, _localizationService.GetResource("ActivityLog.AddNewCheckoutAttribute"), checkoutAttribute.Name);
SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.CheckoutAttributes.Added"));
return continueEditing ? RedirectToAction("Edit", new { id = checkoutAttribute.Id }) : RedirectToAction("List");
}
//If we got this far, something failed, redisplay form
//tax categories
PrepareTaxCategories(model, null, true);
//Stores
PrepareStoresMappingModel(model, null, true);
//ACL
PrepareAclModel(model, null, true);
return View(model);
}
开发者ID:freemsly,项目名称:grandnode,代码行数:31,代码来源:CheckoutAttributeController.cs
示例11: Edit
public ActionResult Edit(CheckoutAttributeModel model, bool continueEditing)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageCatalog))
return AccessDeniedView();
var checkoutAttribute = _checkoutAttributeService.GetCheckoutAttributeById(model.Id);
if (checkoutAttribute == null)
throw new ArgumentException("No checkout attribute found with the specified id");
if (ModelState.IsValid)
{
checkoutAttribute = model.ToEntity(checkoutAttribute);
_checkoutAttributeService.UpdateCheckoutAttribute(checkoutAttribute);
UpdateAttributeLocales(checkoutAttribute, model);
//activity log
_customerActivityService.InsertActivity("EditCheckoutAttribute", _localizationService.GetResource("ActivityLog.EditCheckoutAttribute"), checkoutAttribute.Name);
SuccessNotification(_localizationService.GetResource("Admin.Catalog.Attributes.CheckoutAttributes.Updated"));
return continueEditing ? RedirectToAction("Edit", checkoutAttribute.Id) : RedirectToAction("List");
}
//If we got this far, something failed, redisplay form
PrepareCheckoutAttributeModel(model, checkoutAttribute, true);
return View(model);
}
开发者ID:cmcginn,项目名称:StoreFront,代码行数:26,代码来源:CheckoutAttributeController.cs
示例12: SaveConditionAttributes
protected virtual void SaveConditionAttributes(CheckoutAttribute checkoutAttribute, CheckoutAttributeModel model)
{
string attributesXml = null;
if (model.ConditionModel.EnableCondition)
{
var attribute = _checkoutAttributeService.GetCheckoutAttributeById(model.ConditionModel.SelectedAttributeId);
if (attribute != null)
{
switch (attribute.AttributeControlType)
{
case AttributeControlType.DropdownList:
case AttributeControlType.RadioList:
case AttributeControlType.ColorSquares:
case AttributeControlType.ImageSquares:
{
var selectedAttribute = model.ConditionModel.ConditionAttributes
.FirstOrDefault(x => x.Id == model.ConditionModel.SelectedAttributeId);
var selectedValue = selectedAttribute != null ? selectedAttribute.SelectedValueId : null;
if (!String.IsNullOrEmpty(selectedValue))
attributesXml = _checkoutAttributeParser.AddCheckoutAttribute(attributesXml, attribute, selectedValue);
else
//for conditions we should empty values save even when nothing is selected
//otherwise "attributesXml" will be empty
//hence we won't be able to find a selected attribute
attributesXml = _checkoutAttributeParser.AddCheckoutAttribute(attributesXml, attribute, string.Empty);
}
break;
case AttributeControlType.Checkboxes:
{
var selectedAttribute = model.ConditionModel.ConditionAttributes
.FirstOrDefault(x => x.Id == model.ConditionModel.SelectedAttributeId);
var selectedValues = selectedAttribute != null ? selectedAttribute.Values.Where(x => x.Selected).Select(x => x.Value) : null;
if (selectedValues.Any())
foreach (var value in selectedValues)
attributesXml = _checkoutAttributeParser.AddCheckoutAttribute(attributesXml, attribute, value);
else
attributesXml = _checkoutAttributeParser.AddCheckoutAttribute(attributesXml, attribute, string.Empty);
}
break;
case AttributeControlType.ReadonlyCheckboxes:
case AttributeControlType.TextBox:
case AttributeControlType.MultilineTextbox:
case AttributeControlType.Datepicker:
case AttributeControlType.FileUpload:
default:
//these attribute types are not supported as conditions
break;
}
}
}
checkoutAttribute.ConditionAttributeXml = attributesXml;
}
开发者ID:nvolpe,项目名称:raver,代码行数:52,代码来源:CheckoutAttributeController.cs
示例13: PrepareConditionAttributes
protected virtual void PrepareConditionAttributes(CheckoutAttributeModel model, CheckoutAttribute checkoutAttribute)
{
if (model == null)
throw new ArgumentNullException("model");
//currenty any checkout attribute can have condition.
model.ConditionAllowed = true;
if (checkoutAttribute == null)
return;
var selectedAttribute = _checkoutAttributeParser.ParseCheckoutAttributes(checkoutAttribute.ConditionAttributeXml).FirstOrDefault();
var selectedValues = _checkoutAttributeParser.ParseCheckoutAttributeValues(checkoutAttribute.ConditionAttributeXml);
model.ConditionModel = new ConditionModel()
{
EnableCondition = !string.IsNullOrEmpty(checkoutAttribute.ConditionAttributeXml),
SelectedAttributeId = selectedAttribute != null ? selectedAttribute.Id : 0,
ConditionAttributes = _checkoutAttributeService.GetAllCheckoutAttributes()
//ignore this attribute and non-combinable attributes
.Where(x => x.Id != checkoutAttribute.Id && x.CanBeUsedAsCondition())
.Select(x =>
new AttributeConditionModel()
{
Id = x.Id,
Name = x.Name,
AttributeControlType = x.AttributeControlType,
Values = _checkoutAttributeService.GetCheckoutAttributeValues(x.Id)
.Select(v => new SelectListItem() { Text = v.Name, Value = v.Id.ToString(),
Selected = selectedAttribute != null && selectedAttribute.Id == x.Id && selectedValues.Any(sv => sv.Id == v.Id) }).ToList()
}).ToList()
};
}
开发者ID:nvolpe,项目名称:raver,代码行数:33,代码来源:CheckoutAttributeController.cs
示例14: PrepareStoresMappingModel
protected virtual void PrepareStoresMappingModel(CheckoutAttributeModel model, CheckoutAttribute checkoutAttribute, bool excludeProperties)
{
if (model == null)
throw new ArgumentNullException("model");
if (!excludeProperties && checkoutAttribute != null)
model.SelectedStoreIds = _storeMappingService.GetStoresIdsWithAccess(checkoutAttribute).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)
});
}
}
开发者ID:nvolpe,项目名称:raver,代码行数:19,代码来源:CheckoutAttributeController.cs
注:本文中的CheckoutAttributeModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论