本文整理汇总了C#中Nop.Core.Domain.Orders.CheckoutAttributeValue类的典型用法代码示例。如果您正苦于以下问题:C# CheckoutAttributeValue类的具体用法?C# CheckoutAttributeValue怎么用?C# CheckoutAttributeValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CheckoutAttributeValue类属于Nop.Core.Domain.Orders命名空间,在下文中一共展示了CheckoutAttributeValue类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_save_and_load_checkoutAttributeValue
public void Can_save_and_load_checkoutAttributeValue()
{
var cav = new CheckoutAttributeValue
{
Name = "Name 2",
ColorSquaresRgb = "#112233",
PriceAdjustment = 1.1M,
WeightAdjustment = 2.1M,
IsPreSelected = true,
DisplayOrder = 3,
CheckoutAttribute = new CheckoutAttribute
{
Name = "Name 1",
TextPrompt = "TextPrompt 1",
IsRequired = true,
ShippableProductRequired = true,
IsTaxExempt = true,
TaxCategoryId = 1,
AttributeControlType = AttributeControlType.Datepicker,
DisplayOrder = 2
}
};
var fromDb = SaveAndLoadEntity(cav);
fromDb.ShouldNotBeNull();
fromDb.Name.ShouldEqual("Name 2");
fromDb.ColorSquaresRgb.ShouldEqual("#112233");
fromDb.PriceAdjustment.ShouldEqual(1.1M);
fromDb.WeightAdjustment.ShouldEqual(2.1M);
fromDb.IsPreSelected.ShouldEqual(true);
fromDb.DisplayOrder.ShouldEqual(3);
fromDb.CheckoutAttribute.ShouldNotBeNull();
fromDb.CheckoutAttribute.Name.ShouldEqual("Name 1");
}
示例2: DeleteCheckoutAttributeValue
/// <summary>
/// Deletes a checkout attribute value
/// </summary>
/// <param name="checkoutAttributeValue">Checkout attribute value</param>
public virtual void DeleteCheckoutAttributeValue(CheckoutAttributeValue checkoutAttributeValue)
{
if (checkoutAttributeValue == null)
throw new ArgumentNullException("checkoutAttributeValue");
_checkoutAttributeValueRepository.Delete(checkoutAttributeValue);
_cacheManager.RemoveByPattern(CHECKOUTATTRIBUTES_PATTERN_KEY);
_cacheManager.RemoveByPattern(CHECKOUTATTRIBUTEVALUES_PATTERN_KEY);
//event notification
_eventPublisher.EntityDeleted(checkoutAttributeValue);
}
示例3: UpdateValueLocales
protected virtual void UpdateValueLocales(CheckoutAttributeValue checkoutAttributeValue, CheckoutAttributeValueModel model)
{
foreach (var localized in model.Locales)
{
_localizedEntityService.SaveLocalizedValue(checkoutAttributeValue,
x => x.Name,
localized.Name,
localized.LanguageId);
}
}
示例4: ValueCreatePopup
public ActionResult ValueCreatePopup(string btnId, string formId, CheckoutAttributeValueModel model)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageAttributes))
return AccessDeniedView();
var checkoutAttribute = _checkoutAttributeService.GetCheckoutAttributeById(model.CheckoutAttributeId);
if (checkoutAttribute == null)
//No checkout attribute found with the specified id
return RedirectToAction("List");
model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
model.BaseWeightIn = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId).Name;
if (checkoutAttribute.AttributeControlType == AttributeControlType.ColorSquares)
{
//ensure valid color is chosen/entered
if (String.IsNullOrEmpty(model.ColorSquaresRgb))
ModelState.AddModelError("", "Color is required");
try
{
//ensure color is valid (can be instanciated)
System.Drawing.ColorTranslator.FromHtml(model.ColorSquaresRgb);
}
catch (Exception exc)
{
ModelState.AddModelError("", exc.Message);
}
}
if (ModelState.IsValid)
{
var cav = new CheckoutAttributeValue
{
CheckoutAttributeId = model.CheckoutAttributeId,
Name = model.Name,
ColorSquaresRgb = model.ColorSquaresRgb,
PriceAdjustment = model.PriceAdjustment,
WeightAdjustment = model.WeightAdjustment,
IsPreSelected = model.IsPreSelected,
DisplayOrder = model.DisplayOrder
};
_checkoutAttributeService.InsertCheckoutAttributeValue(cav);
UpdateValueLocales(cav, model);
ViewBag.RefreshPage = true;
ViewBag.btnId = btnId;
ViewBag.formId = formId;
return View(model);
}
//If we got this far, something failed, redisplay form
return View(model);
}
示例5: GetCheckoutAttributePrice
/// <summary>
/// Gets checkout attribute value price
/// </summary>
/// <param name="cav">Checkout attribute value</param>
/// <param name="includingTax">A value indicating whether calculated price should include tax</param>
/// <param name="customer">Customer</param>
/// <param name="taxRate">Tax rate</param>
/// <returns>Price</returns>
public virtual decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav,
bool includingTax, Customer customer, out decimal taxRate)
{
if (cav == null)
throw new ArgumentNullException("cav");
taxRate = decimal.Zero;
decimal price = cav.PriceAdjustment;
if (cav.CheckoutAttribute.IsTaxExempt)
{
return price;
}
bool priceIncludesTax = _taxSettings.PricesIncludeTax;
int taxClassId = cav.CheckoutAttribute.TaxCategoryId;
return GetProductPrice(null, taxClassId, price, includingTax, customer,
priceIncludesTax, out taxRate);
}
示例6: GetCheckoutAttributePrice
/// <summary>
/// Gets checkout attribute value price
/// </summary>
/// <param name="cav">Checkout attribute value</param>
/// <param name="customer">Customer</param>
/// <returns>Price</returns>
public virtual decimal GetCheckoutAttributePrice(CheckoutAttributeValue cav, Customer customer)
{
bool includingTax = false;
switch (_workContext.TaxDisplayType)
{
case TaxDisplayType.ExcludingTax:
includingTax = false;
break;
case TaxDisplayType.IncludingTax:
includingTax = true;
break;
}
return GetCheckoutAttributePrice(cav, includingTax, customer);
}
示例7: SetUp
public new void SetUp()
{
#region Test data
//color (dropdownlist)
ca1 = new CheckoutAttribute
{
Id = 1,
Name= "Color",
TextPrompt = "Select color:",
IsRequired = true,
AttributeControlType = AttributeControlType.DropdownList,
DisplayOrder = 1,
};
cav1_1 = new CheckoutAttributeValue
{
Id = 11,
Name = "Green",
DisplayOrder = 1,
CheckoutAttribute = ca1,
CheckoutAttributeId = ca1.Id,
};
cav1_2 = new CheckoutAttributeValue
{
Id = 12,
Name = "Red",
DisplayOrder = 2,
CheckoutAttribute = ca1,
CheckoutAttributeId = ca1.Id,
};
ca1.CheckoutAttributeValues.Add(cav1_1);
ca1.CheckoutAttributeValues.Add(cav1_2);
//custom option (checkboxes)
ca2 = new CheckoutAttribute
{
Id = 2,
Name = "Custom option",
TextPrompt = "Select custom option:",
IsRequired = true,
AttributeControlType = AttributeControlType.Checkboxes,
DisplayOrder = 2,
};
cav2_1 = new CheckoutAttributeValue
{
Id = 21,
Name = "Option 1",
DisplayOrder = 1,
CheckoutAttribute = ca2,
CheckoutAttributeId = ca2.Id,
};
cav2_2 = new CheckoutAttributeValue
{
Id = 22,
Name = "Option 2",
DisplayOrder = 2,
CheckoutAttribute = ca2,
CheckoutAttributeId = ca2.Id,
};
ca2.CheckoutAttributeValues.Add(cav2_1);
ca2.CheckoutAttributeValues.Add(cav2_2);
//custom text
ca3 = new CheckoutAttribute
{
Id = 3,
Name = "Custom text",
TextPrompt = "Enter custom text:",
IsRequired = true,
AttributeControlType = AttributeControlType.MultilineTextbox,
DisplayOrder = 3,
};
#endregion
_checkoutAttributeRepo = MockRepository.GenerateMock<IRepository<CheckoutAttribute>>();
_checkoutAttributeRepo.Expect(x => x.Table).Return(new List<CheckoutAttribute> { ca1, ca2, ca3 }.AsQueryable());
_checkoutAttributeRepo.Expect(x => x.GetById(ca1.Id)).Return(ca1);
_checkoutAttributeRepo.Expect(x => x.GetById(ca2.Id)).Return(ca2);
_checkoutAttributeRepo.Expect(x => x.GetById(ca3.Id)).Return(ca3);
_checkoutAttributeValueRepo = MockRepository.GenerateMock<IRepository<CheckoutAttributeValue>>();
_checkoutAttributeValueRepo.Expect(x => x.Table).Return(new List<CheckoutAttributeValue> { cav1_1, cav1_2, cav2_1, cav2_2 }.AsQueryable());
_checkoutAttributeValueRepo.Expect(x => x.GetById(cav1_1.Id)).Return(cav1_1);
_checkoutAttributeValueRepo.Expect(x => x.GetById(cav1_2.Id)).Return(cav1_2);
_checkoutAttributeValueRepo.Expect(x => x.GetById(cav2_1.Id)).Return(cav2_1);
_checkoutAttributeValueRepo.Expect(x => x.GetById(cav2_2.Id)).Return(cav2_2);
var cacheManager = new NopNullCache();
_storeMappingService = MockRepository.GenerateMock<IStoreMappingService>();
_eventPublisher = MockRepository.GenerateMock<IEventPublisher>();
_eventPublisher.Expect(x => x.Publish(Arg<object>.Is.Anything));
_checkoutAttributeService = new CheckoutAttributeService(cacheManager,
_checkoutAttributeRepo,
_checkoutAttributeValueRepo,
_storeMappingService,
_eventPublisher);
//.........这里部分代码省略.........
示例8: UpdateValueLocales
protected virtual List<LocalizedProperty> UpdateValueLocales(CheckoutAttributeValue checkoutAttributeValue, CheckoutAttributeValueModel 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,
});
}
return localized;
}
示例9: ToEntity
public static CheckoutAttributeValue ToEntity(this CheckoutAttributeValueModel model, CheckoutAttributeValue destination)
{
return Mapper.Map(model, destination);
}