本文整理汇总了C#中Nop.Core.Domain.Catalog.TierPrice类的典型用法代码示例。如果您正苦于以下问题:C# TierPrice类的具体用法?C# TierPrice怎么用?C# TierPrice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TierPrice类属于Nop.Core.Domain.Catalog命名空间,在下文中一共展示了TierPrice类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_save_and_load_tierPrice
public void Can_save_and_load_tierPrice()
{
var tierPrice = new TierPrice
{
Quantity = 1,
Price = 2.1M,
ProductVariant = GetTestProductVariant(),
};
var fromDb = SaveAndLoadEntity(tierPrice);
fromDb.ShouldNotBeNull();
fromDb.Quantity.ShouldEqual(1);
fromDb.Price.ShouldEqual(2.1M);
fromDb.ProductVariant.ShouldNotBeNull();
fromDb.ProductVariant.Name.ShouldEqual("Product variant name 1");
}
示例2: Can_save_and_load_tierPrice
public void Can_save_and_load_tierPrice()
{
var tierPrice = new TierPrice
{
StoreId = 7,
Quantity = 1,
Price = 2.1M,
Product = GetTestProduct(),
};
var fromDb = SaveAndLoadEntity(tierPrice);
fromDb.ShouldNotBeNull();
fromDb.StoreId.ShouldEqual(7);
fromDb.Quantity.ShouldEqual(1);
fromDb.Price.ShouldEqual(2.1M);
fromDb.Product.ShouldNotBeNull();
}
示例3: Can_save_and_load_tierPriceWithCustomerRole
public void Can_save_and_load_tierPriceWithCustomerRole()
{
var tierPrice = new TierPrice
{
Quantity = 1,
Price = 2,
Product = GetTestProduct(),
CustomerRole = new CustomerRole()
{
Name = "Administrators",
FreeShipping = true,
TaxExempt = true,
Active = true,
IsSystemRole = true,
SystemName = "Administrators"
}
};
var fromDb = SaveAndLoadEntity(tierPrice);
fromDb.ShouldNotBeNull();
fromDb.CustomerRole.ShouldNotBeNull();
fromDb.CustomerRole.Name.ShouldEqual("Administrators");
}
示例4: DeleteTierPrice
/// <summary>
/// Deletes a tier price
/// </summary>
/// <param name="tierPrice">Tier price</param>
public virtual void DeleteTierPrice(TierPrice tierPrice)
{
if (tierPrice == null)
throw new ArgumentNullException("tierPrice");
_tierPriceRepository.Delete(tierPrice);
_cacheManager.RemoveByPattern(PRODUCTS_PATTERN_KEY);
//event notification
_eventPublisher.EntityDeleted(tierPrice);
}
示例5: InsertTierPrice
/// <summary>
/// Inserts a tier price
/// </summary>
/// <param name="tierPrice">Tier price</param>
public virtual void InsertTierPrice(TierPrice tierPrice)
{
if (tierPrice == null)
throw new ArgumentNullException("tierPrice");
_tierPriceRepository.Insert(tierPrice);
_cacheManager.RemoveByPattern(PRODUCTS_PATTERN_KEY);
_cacheManager.RemoveByPattern(PRODUCTVARIANTS_PATTERN_KEY);
_cacheManager.RemoveByPattern(TIERPRICES_PATTERN_KEY);
//event notification
_eventPublisher.EntityInserted(tierPrice);
}
示例6: TierPriceInsert
public ActionResult TierPriceInsert(ProductModel.TierPriceModel model)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
return AccessDeniedView();
var product = _productService.GetProductById(model.ProductId);
if (product == null)
throw new ArgumentException("No product found with the specified id");
//a vendor should have access only to his products
if (_workContext.CurrentVendor != null && product.VendorId != _workContext.CurrentVendor.Id)
return Content("This is not your product");
var tierPrice = new TierPrice
{
ProductId = model.ProductId,
StoreId = model.StoreId,
CustomerRoleId = model.CustomerRoleId > 0 ? model.CustomerRoleId : (int?)null,
Quantity = model.Quantity,
Price = model.Price
};
_productService.InsertTierPrice(tierPrice);
//update "HasTierPrices" property
_productService.UpdateHasTierPricesProperty(product);
return new NullJsonResult();
}
示例7: UpdateTierPrice
/// <summary>
/// Updates the tier price
/// </summary>
/// <param name="tierPrice">Tier price</param>
public virtual void UpdateTierPrice(TierPrice tierPrice)
{
if (tierPrice == null)
throw new ArgumentNullException("tierPrice");
var builder = Builders<Product>.Filter;
var filter = builder.Eq(x => x.Id, tierPrice.ProductId);
filter = filter & builder.Where(x => x.TierPrices.Any(y => y.Id == tierPrice.Id));
var update = Builders<Product>.Update
.Set(x => x.TierPrices.ElementAt(-1).Price, tierPrice.Price)
.Set(x => x.TierPrices.ElementAt(-1).Quantity, tierPrice.Quantity)
.Set(x => x.TierPrices.ElementAt(-1).StoreId, tierPrice.StoreId)
.Set(x => x.TierPrices.ElementAt(-1).CustomerRoleId, tierPrice.CustomerRoleId);
var result = _productRepository.Collection.UpdateManyAsync(filter, update).Result;
//cache
_cacheManager.RemoveByPattern(string.Format(PRODUCTS_BY_ID_KEY, tierPrice.ProductId));
//event notification
_eventPublisher.EntityUpdated(tierPrice);
}
示例8: InsertTierPrice
/// <summary>
/// Inserts a tier price
/// </summary>
/// <param name="tierPrice">Tier price</param>
public virtual void InsertTierPrice(TierPrice tierPrice)
{
if (tierPrice == null)
throw new ArgumentNullException("tierPrice");
//_tierPriceRepository.Insert(tierPrice);
var updatebuilder = Builders<Product>.Update;
var update = updatebuilder.AddToSet(p => p.TierPrices, tierPrice);
_productRepository.Collection.UpdateOneAsync(new BsonDocument("Id", tierPrice.ProductId), update);
//cache
_cacheManager.RemoveByPattern(string.Format(PRODUCTS_BY_ID_KEY, tierPrice.ProductId));
//event notification
_eventPublisher.EntityInserted(tierPrice);
}