本文整理汇总了C#中Nop.Core.Domain.Catalog.Product类的典型用法代码示例。如果您正苦于以下问题:C# Product类的具体用法?C# Product怎么用?C# Product使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Product类属于Nop.Core.Domain.Catalog命名空间,在下文中一共展示了Product类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Two_references_to_same_transient_entity_should_be_equal
public void Two_references_to_same_transient_entity_should_be_equal() {
var p1 = new Product();
var p2 = p1;
Assert.AreEqual(p1, p2, "Two references to the same transient entity should be equal");
}
示例2: PrepareProductSpecificationModel
public static IList<ProductSpecificationModel> PrepareProductSpecificationModel(this Controller controller,
IWorkContext workContext,
ISpecificationAttributeService specificationAttributeService,
ICacheManager cacheManager,
Product product)
{
if (product == null)
throw new ArgumentNullException("product");
string cacheKey = string.Format(ModelCacheEventConsumer.PRODUCT_SPECS_MODEL_KEY, product.Id, workContext.WorkingLanguage.Id);
return cacheManager.Get(cacheKey, () =>
{
var model = specificationAttributeService.GetProductSpecificationAttributesByProductId(product.Id, null, true)
.Select(psa =>
{
return new ProductSpecificationModel()
{
SpecificationAttributeId = psa.SpecificationAttributeOption.SpecificationAttributeId,
SpecificationAttributeName = psa.SpecificationAttributeOption.SpecificationAttribute.GetLocalized(x => x.Name),
SpecificationAttributeOption = !String.IsNullOrEmpty(psa.CustomValue) ? psa.CustomValue : psa.SpecificationAttributeOption.GetLocalized(x => x.Name),
};
}).ToList();
return model;
});
}
示例3: GetDiscountAmount
/// <summary>
/// Gets discount amount
/// </summary>
/// <param name="product">Product</param>
/// <param name="customer">The customer</param>
/// <param name="additionalCharge">Additional charge</param>
/// <returns>Discount amount</returns>
public virtual decimal GetDiscountAmount(Product product,
Customer customer,
decimal additionalCharge = decimal.Zero)
{
Discount appliedDiscount = null;
return GetDiscountAmount(product, customer, additionalCharge, out appliedDiscount);
}
示例4: Can_calculate_rental_periods_for_days
public void Can_calculate_rental_periods_for_days()
{
var product = new Product
{
IsRental = true,
RentalPricePeriod = RentalPricePeriod.Days
};
//rental period length = 1 day
product.RentalPriceLength = 1;
//the same date
product.GetRentalPeriods(new DateTime(2014, 3, 5), new DateTime(2014, 3, 5)).ShouldEqual(1);
//1 day
product.GetRentalPeriods(new DateTime(2014, 3, 5), new DateTime(2014, 3, 6)).ShouldEqual(1);
//2 days
product.GetRentalPeriods(new DateTime(2014, 3, 5), new DateTime(2014, 3, 7)).ShouldEqual(2);
//3 days
product.GetRentalPeriods(new DateTime(2014, 3, 5), new DateTime(2014, 3, 8)).ShouldEqual(3);
//rental period length = 2 days
product.RentalPriceLength = 2;
//the same date
product.GetRentalPeriods(new DateTime(2014, 3, 5), new DateTime(2014, 3, 5)).ShouldEqual(1);
//1 day
product.GetRentalPeriods(new DateTime(2014, 3, 5), new DateTime(2014, 3, 6)).ShouldEqual(1);
//2 days
product.GetRentalPeriods(new DateTime(2014, 3, 5), new DateTime(2014, 3, 7)).ShouldEqual(1);
//3 days
product.GetRentalPeriods(new DateTime(2014, 3, 5), new DateTime(2014, 3, 8)).ShouldEqual(2);
}
示例5: Can_calculate_total_quantity_when_we_do_use_multiple_warehouses_with_reserved
public void Can_calculate_total_quantity_when_we_do_use_multiple_warehouses_with_reserved()
{
var product = new Product
{
ManageInventoryMethod = ManageInventoryMethod.ManageStock,
UseMultipleWarehouses = true,
StockQuantity = 6,
};
product.ProductWarehouseInventory.Add(new ProductWarehouseInventory
{
WarehouseId = 1,
StockQuantity = 7,
ReservedQuantity = 4,
});
product.ProductWarehouseInventory.Add(new ProductWarehouseInventory
{
WarehouseId = 2,
StockQuantity = 8,
ReservedQuantity = 1,
});
product.ProductWarehouseInventory.Add(new ProductWarehouseInventory
{
WarehouseId = 3,
StockQuantity = -2,
});
var result = product.GetTotalStockQuantity(true);
result.ShouldEqual(8);
}
示例6: Entities_with_different_id_should_not_be_equal
public void Entities_with_different_id_should_not_be_equal() {
var p1 = new Product { Id = 2 };
var p2 = new Product { Id = 5 };
Assert.AreNotEqual(p1, p2, "Entities with different ids should not be equal");
}
示例7: Two_transient_entities_should_not_be_equal
public void Two_transient_entities_should_not_be_equal() {
var p1 = new Product();
var p2 = new Product();
Assert.AreNotEqual(p1, p2, "Different transient entities should not be equal");
}
示例8: SendProductInquery
public virtual int SendProductInquery(Product product,Vendor vendor,string from,string phone, string email,string msg, int languageId)
{
if (product == null)
throw new ArgumentNullException("product");
var store = _storeContext.CurrentStore;
languageId = EnsureLanguageIsActive(languageId, store.Id);
var messageTemplate = GetActiveMessageTemplate("Product.Inqure", store.Id);
if (messageTemplate == null)
return 0;
//email account
var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate, languageId);
//tokens
var tokens = new List<Token>();
_messageTokenProvider.AddStoreTokens(tokens, store, emailAccount);
tokens.Add(new Token("Product.ProductUrl", store.Url + product.Name.Trim().Replace(" ", "-")));
tokens.Add(new Token("Product.ProductName", product.Name));
tokens.Add(new Token("From", from));
tokens.Add(new Token("Phone", phone));
tokens.Add(new Token("Email", email));
tokens.Add(new Token("Msg", msg));
//event notification
_eventPublisher.MessageTokensAdded(messageTemplate, tokens);
var toEmail = vendor.Email;
var toName = vendor.Name;
return SendNotification(messageTemplate, emailAccount,
languageId, tokens,
toEmail, toName);
}
示例9: Entity_should_not_equal_transient_entity
public void Entity_should_not_equal_transient_entity() {
var p1 = new Product { Id = 1 };
var p2 = new Product();
Assert.AreNotEqual(p1, p2, "Entity and transient entity should not be equal");
}
示例10: Can_save_and_load_product_with_productVariants
public void Can_save_and_load_product_with_productVariants()
{
var product = new Product
{
Name = "Name 1",
Published = true,
Deleted = false,
CreatedOnUtc = new DateTime(2010, 01, 01),
UpdatedOnUtc = new DateTime(2010, 01, 02)
};
product.ProductVariants.Add
(
new ProductVariant
{
Name = "Product variant name 1",
CreatedOnUtc = new DateTime(2010, 01, 03),
UpdatedOnUtc = new DateTime(2010, 01, 04)
}
);
var fromDb = SaveAndLoadEntity(product);
fromDb.ShouldNotBeNull();
fromDb.Name.ShouldEqual("Name 1");
fromDb.ProductVariants.ShouldNotBeNull();
(fromDb.ProductVariants.Count == 1).ShouldBeTrue();
fromDb.ProductVariants.First().Name.ShouldEqual("Product variant name 1");
}
示例11: Can_check_taxExempt_product
public void Can_check_taxExempt_product()
{
var product = new Product();
product.IsTaxExempt = true;
_taxService.IsTaxExempt(product, null).ShouldEqual(true);
product.IsTaxExempt = false;
_taxService.IsTaxExempt(product, null).ShouldEqual(false);
}
示例12: Entities_with_same_id_but_different_type_should_not_be_equal
public void Entities_with_same_id_but_different_type_should_not_be_equal() {
int id = 10;
var p1 = new Product { Id = id };
var c1 = new Category { Id = id };
Assert.AreNotEqual(p1, c1, "Entities of different types should not be equal, even if they have the same id");
}
示例13: Two_references_with_the_same_id_should_be_equal
public void Two_references_with_the_same_id_should_be_equal() {
int id = 10;
var p1 = new Product { Id = id };
var p2 = new Product { Id = id };
Assert.AreEqual(p1, p2, "Entities with the same id should be equal");
}
示例14: Should_not_be_available_when_startdate_is_greater_than_somedate
public void Should_not_be_available_when_startdate_is_greater_than_somedate()
{
var product = new Product
{
AvailableStartDateTimeUtc = new DateTime(2010, 01, 02)
};
product.IsAvailable(new DateTime(2010, 01, 01)).ShouldEqual(false);
}
示例15: Should_be_available_when_startdate_is_less_than_somedate
public void Should_be_available_when_startdate_is_less_than_somedate()
{
var product = new Product
{
AvailableStartDateTimeUtc = new DateTime(2010, 01, 02)
};
product.IsAvailable(new DateTime(2010, 01, 03)).ShouldEqual(true);
}