當前位置: 首頁>>代碼示例>>C#>>正文


C# Catalog.Product類代碼示例

本文整理匯總了C#中SmartStore.Core.Domain.Catalog.Product的典型用法代碼示例。如果您正苦於以下問題:C# Product類的具體用法?C# Product怎麽用?C# Product使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Product類屬於SmartStore.Core.Domain.Catalog命名空間,在下文中一共展示了Product類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Can_delete_mappings_for_entity

        public void Can_delete_mappings_for_entity()
        {
            var product = new Product { Id = 5 };

            _service.DeleteSyncMappingsFor(product);
            _rs.Table.Count().ShouldEqual(38);
        }
開發者ID:mandocaesar,項目名稱:Mesinku,代碼行數:7,代碼來源:SyncMappingServiceTests.cs

示例2: 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");
        }
開發者ID:JeffersonNascimento,項目名稱:SmartStoreNET,代碼行數:7,代碼來源:EntityEqualityTests.cs

示例3: 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");
        }
開發者ID:JeffersonNascimento,項目名稱:SmartStoreNET,代碼行數:7,代碼來源:EntityEqualityTests.cs

示例4: 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");
        }
開發者ID:JeffersonNascimento,項目名稱:SmartStoreNET,代碼行數:7,代碼來源:EntityEqualityTests.cs

示例5: 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");
        }
開發者ID:JeffersonNascimento,項目名稱:SmartStoreNET,代碼行數:7,代碼來源:EntityEqualityTests.cs

示例6: 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");
        }
開發者ID:JeffersonNascimento,項目名稱:SmartStoreNET,代碼行數:8,代碼來源:EntityEqualityTests.cs

示例7: 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);
 }
開發者ID:GloriousOnion,項目名稱:SmartStoreNET,代碼行數:8,代碼來源:TaxServiceTests.cs

示例8: 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");
        }
開發者ID:JeffersonNascimento,項目名稱:SmartStoreNET,代碼行數:8,代碼來源:EntityEqualityTests.cs

示例9: CreateAllProductVariantAttributeCombinations

        public virtual void CreateAllProductVariantAttributeCombinations(Product product)
        {
            // delete all existing combinations
            foreach(var itm in product.ProductVariantAttributeCombinations)
            {
                DeleteProductVariantAttributeCombination(itm);
            }

            var attributes = GetProductVariantAttributesByProductId(product.Id);
            if (attributes == null || attributes.Count <= 0)
                return;

            var toCombine = new List<List<ProductVariantAttributeValue>>();
            var resultMatrix = new List<List<ProductVariantAttributeValue>>();
            var tmp = new List<ProductVariantAttributeValue>();

            foreach (var attr in attributes)
            {
                var attributeValues = attr.ProductVariantAttributeValues.ToList();
                if (attributeValues.Count > 0)
                    toCombine.Add(attributeValues);
            }

            if (toCombine.Count > 0)
            {
                CombineAll(toCombine, resultMatrix, 0, tmp);

                foreach (var values in resultMatrix)
                {
                    string attrXml = "";
                    foreach (var x in values)
                    {
                        attrXml = attributes[values.IndexOf(x)].AddProductAttribute(attrXml, x.Id.ToString());
                    }

                    var combination = new ProductVariantAttributeCombination
                    {
                        ProductId = product.Id,
                        AttributesXml = attrXml,
                        StockQuantity = 10000,
                        AllowOutOfStockOrders = true,
                        IsActive = true
                    };

                    _productVariantAttributeCombinationRepository.Insert(combination);
                    _eventPublisher.EntityInserted(combination);
                }
            }

            //foreach (var y in resultMatrix) {
            //	StringBuilder sb = new StringBuilder();
            //	foreach (var x in y) {
            //		sb.AppendFormat("{0} ", x.Name);
            //	}
            //	sb.ToString().Dump();
            //}
        }
開發者ID:mandocaesar,項目名稱:Mesinku,代碼行數:57,代碼來源:ProductAttributeService.cs

示例10: Can_load_mapping_by_entity

        public void Can_load_mapping_by_entity()
        {
            var product = new Product { Id = 5 };

            var mapping = _service.GetSyncMappingByEntity(product, "App2");
            Assert.NotNull(mapping);
            mapping.EntityName.ShouldEqual("Product");
            mapping.EntityId.ShouldEqual(5);
            mapping.SourceKey.ShouldEqual("e5");
        }
開發者ID:mandocaesar,項目名稱:Mesinku,代碼行數:10,代碼來源:SyncMappingServiceTests.cs

示例11: Equality_works_using_operators

        public void Equality_works_using_operators() {

            var p1 = new Product { Id = 1 };
            var p2 = new Product { Id = 1 };

            Assert.IsTrue(p1 == p2);

            var p3 = new Product();

            Assert.IsTrue(p1 != p3);
        }
開發者ID:JeffersonNascimento,項目名稱:SmartStoreNET,代碼行數:11,代碼來源:EntityEqualityTests.cs

示例12: Can_parse_required_product_ids

		public void Can_parse_required_product_ids()
		{
			var product = new Product
			{
				RequiredProductIds = "1, 4,7 ,a,"
			};

			var ids = product.ParseRequiredProductIds();
			ids.Length.ShouldEqual(3);
			ids[0].ShouldEqual(1);
			ids[1].ShouldEqual(4);
			ids[2].ShouldEqual(7);
		}
開發者ID:JeffersonNascimento,項目名稱:SmartStoreNET,代碼行數:13,代碼來源:ProductExtensionTests.cs

示例13: Can_parse_allowed_quantities

        public void Can_parse_allowed_quantities()
        {
            var product = new Product()
            {
                AllowedQuantities = "1, 5,4,10,sdf"
            };

            var result = product.ParseAllowedQuatities();
            result.Length.ShouldEqual(4);
            result[0].ShouldEqual(1);
            result[1].ShouldEqual(5);
            result[2].ShouldEqual(4);
            result[3].ShouldEqual(10);
        }
開發者ID:JeffersonNascimento,項目名稱:SmartStoreNET,代碼行數:14,代碼來源:ProductExtensionTests.cs

示例14: GetAllowedDiscounts

        /// <summary>
        /// Gets allowed discounts
        /// </summary>
		/// <param name="product">Product</param>
        /// <param name="customer">Customer</param>
        /// <returns>Discounts</returns>
        protected virtual IList<Discount> GetAllowedDiscounts(Product product, Customer customer)
        {
            var allowedDiscounts = new List<Discount>();
            if (_catalogSettings.IgnoreDiscounts)
                return allowedDiscounts;

			if (product.HasDiscountsApplied)
            {
                //we use this property ("HasDiscountsApplied") for performance optimziation to avoid unnecessary database calls
				foreach (var discount in product.AppliedDiscounts)
                {
					if (_discountService.IsDiscountValid(discount, customer) &&
						discount.DiscountType == DiscountType.AssignedToSkus &&
						!allowedDiscounts.ContainsDiscount(discount))
					{
						allowedDiscounts.Add(discount);
					}
                }
            }

            //performance optimization
            //load all category discounts just to ensure that we have at least one
            if (_discountService.GetAllDiscounts(DiscountType.AssignedToCategories).Any())
            {
				var productCategories = _categoryService.GetProductCategoriesByProductId(product.Id);
                if (productCategories != null)
                {
                    foreach (var productCategory in productCategories)
                    {
                        var category = productCategory.Category;

                        if (category.HasDiscountsApplied)
                        {
                            //we use this property ("HasDiscountsApplied") for performance optimziation to avoid unnecessary database calls
                            var categoryDiscounts = category.AppliedDiscounts;
                            foreach (var discount in categoryDiscounts)
                            {
								if (_discountService.IsDiscountValid(discount, customer) &&
									discount.DiscountType == DiscountType.AssignedToCategories &&
									!allowedDiscounts.ContainsDiscount(discount))
								{
									allowedDiscounts.Add(discount);
								}
                            }
                        }
                    }
                }
            }
            return allowedDiscounts;
        }
開發者ID:boatengfrankenstein,項目名稱:SmartStoreNET,代碼行數:56,代碼來源:PriceCalculationService.cs

示例15: Can_get_final_product_price_with_additionalFee

        public void Can_get_final_product_price_with_additionalFee()
        {
            var product = new Product
            {
                Id = 1,
                Name = "Product name 1",
                Price = 12.34M,
                CustomerEntersPrice = false,
                Published = true,
            };

            //customer
            Customer customer = null;

            _priceCalcService.GetFinalPrice(product, customer, 5, false, 1).ShouldEqual(17.34M);
        }
開發者ID:mandocaesar,項目名稱:Mesinku,代碼行數:16,代碼來源:PriceCalculationServiceTests.cs


注:本文中的SmartStore.Core.Domain.Catalog.Product類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。