当前位置: 首页>>代码示例>>C#>>正文


C# IProductVariant类代码示例

本文整理汇总了C#中IProductVariant的典型用法代码示例。如果您正苦于以下问题:C# IProductVariant类的具体用法?C# IProductVariant怎么用?C# IProductVariant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IProductVariant类属于命名空间,在下文中一共展示了IProductVariant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Product

        public Product(IProductVariant variantTemplate, OptionCollection optionCollection)
        {
            Mandate.ParameterNotNull(variantTemplate, "groupTemplate");
            Mandate.ParameterNotNull(optionCollection, "optionCollection");

            _variantTemplate = variantTemplate;
            _optionCollection = optionCollection;
        }
开发者ID:BatJan,项目名称:Merchello,代码行数:8,代码来源:Product.cs

示例2: Product

        public Product(IProductVariant variant, ProductOptionCollection productOptions, ProductVariantCollection productVariants)
        {
            Mandate.ParameterNotNull(variant, "variantMaster");
            Mandate.ParameterNotNull(productOptions, "optionCollection");
            Mandate.ParameterNotNull(productVariants, "productVariants");

            _variant = variant;
            _productOptions = productOptions;
            _productVariants = productVariants;
        }
开发者ID:VDBBjorn,项目名称:Merchello,代码行数:10,代码来源:Product.cs

示例3: AddToCatalog

        /// <summary>
        /// Adds the variants to the catalog.
        /// </summary>
        /// <param name="variant">
        /// The variant.
        /// </param>
        private void AddToCatalog(IProductVariant variant)
        {
            var matching = this.GetOrignalMatchingVariant(variant);
            var catalogKeys = matching.CatalogInventories.Select(x => x.CatalogKey).ToArray();

            foreach (var key in catalogKeys)
            {
                if (variant.CatalogInventories.All(x => x.CatalogKey != key))
                {
                    var catalog = _warehouseCatalogs.Value.FirstOrDefault(x => x.Key == key);
                    if (catalog != null) variant.AddToCatalogInventory(catalog);   
                }
            }
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:20,代码来源:AddProductToWarehouseCatalogsTask.cs

示例4: IndexProductVariant

 private static void IndexProductVariant(IProductVariant productVariant)
 {
     IndexProductVariant(productVariant, null);
 }
开发者ID:naepalm,项目名称:Merchello,代码行数:4,代码来源:MerchelloAllInTestBase.cs

示例5: Save

        /// <summary>
        /// Saves a single instance of a <see cref="IProductVariant"/>
        /// </summary>
        /// <param name="productVariant"></param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IProductVariant productVariant, bool raiseEvents = true)
        {
            if(raiseEvents)
            if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IProductVariant>(productVariant), this))
            {
                ((ProductVariant)productVariant).WasCancelled = true;
                return;
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateProductVariantRepository(uow))
                {
                    repository.AddOrUpdate(productVariant);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            Saved.RaiseEvent(new SaveEventArgs<IProductVariant>(productVariant), this);
        }
开发者ID:ProNotion,项目名称:Merchello,代码行数:27,代码来源:ProductVariantService.cs

示例6: UpdateQuantity

 /// <summary>
 /// Updates a wish list item's quantity
 /// </summary>
 /// <param name="productVariant">
 /// The product Variant.
 /// </param>
 /// <param name="quantity">
 /// The quantity.
 /// </param>
 public void UpdateQuantity(IProductVariant productVariant, int quantity)
 {
     UpdateQuantity(productVariant.Sku, quantity);
 }
开发者ID:arknu,项目名称:Merchello,代码行数:13,代码来源:Wishlist.cs

示例7: AddItem

        /// <summary>
        /// Adds a line item to the wish list
        /// </summary>
        /// <param name="productVariant">
        /// The product Variant.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="quantity">
        /// The quantity.
        /// </param>
        /// <param name="extendedData">
        /// The extended Data.
        /// </param>
        public void AddItem(IProductVariant productVariant, string name, int quantity, ExtendedDataCollection extendedData)
        {
            if (!extendedData.DefinesProductVariant()) extendedData.AddProductVariantValues(productVariant);

            var onSale = productVariant.OnSale ? extendedData.GetSalePriceValue() : extendedData.GetPriceValue();

            AddItem(string.IsNullOrEmpty(name) ? productVariant.Name : name, productVariant.Sku, quantity, onSale, extendedData);
        }
开发者ID:arknu,项目名称:Merchello,代码行数:23,代码来源:Wishlist.cs

示例8: AddItem

 /// <summary>
 /// Adds a line item to the customer item cache
 /// </summary>
 /// <param name="productVariant">
 /// The product Variant.
 /// </param>
 /// <param name="name">
 /// The name.
 /// </param>
 /// <param name="quantity">
 /// The quantity.
 /// </param>
 /// <param name="extendedData">
 /// The extended Data.
 /// </param>
 public void AddItem(IProductVariant productVariant, string name, int quantity, ExtendedDataCollection extendedData)
 {
     AddItem(productVariant.ToProductVariantDisplay(), name, quantity, extendedData);
 }
开发者ID:drpeck,项目名称:Merchello,代码行数:19,代码来源:CustomerItemCacheBase.cs

示例9: AddItem

        /// <summary>
        /// Adds a line item to the basket
        /// </summary>
        public void AddItem(IProductVariant productVariant, string name, int quantity, ExtendedDataCollection extendedData)
        {
            if(!extendedData.DefinesProductVariant()) extendedData.AddProductVariantValues(productVariant);

            AddItem(
                string.IsNullOrEmpty(name) ? productVariant.Name : name,
                productVariant.Sku,
                quantity,
                productVariant.OnSale ?
                extendedData.GetSalePriceValue()
                : extendedData.GetPriceValue(), extendedData); // get the price information from extended data in case it has been overriden

            //productVariant.SalePrice.Value : productVariant.Price
        }
开发者ID:BatJan,项目名称:Merchello,代码行数:17,代码来源:Basket.cs

示例10: GetCatalogInventoriesJson

        private static string GetCatalogInventoriesJson(IProductVariant productVariant)
        {
            var json = "[{0}]";
            var catalogInventories = "";

            foreach (var ch in productVariant.CatalogInventories)
            {
                if (catalogInventories.Length > 0) catalogInventories += ",";
                catalogInventories += JsonConvert.SerializeObject(
                new
                {   catalogKey = ch.CatalogKey,
                    productVariantKey = ch.ProductVariantKey,
                    location = ch.Location,
                    count = ch.Count,
                    lowCount = ch.LowCount
                },
                Formatting.None);
            }
            json = string.Format(json, catalogInventories);
            return json;
        }
开发者ID:biapar,项目名称:Merchello,代码行数:21,代码来源:ProductExtensions.cs

示例11: GetAttributesJson

        private static string GetAttributesJson(IProductVariant productVariant)
        {
            var json = "[{0}]";
            var atts = "";

            foreach (var attribute in productVariant.Attributes)
            {
                if (atts.Length > 0) atts += ",";
                atts += JsonConvert.SerializeObject(
                new
                {
                    key = attribute.Key,
                    optionKey = attribute.OptionKey,
                    name = attribute.Name,
                    sku = attribute.Sku,
                    sortOrder = attribute.SortOrder
                },
                Formatting.None);
            }
            json = string.Format(json, atts);
            return json;
        }
开发者ID:biapar,项目名称:Merchello,代码行数:22,代码来源:ProductExtensions.cs

示例12: Delete

        /// <summary>
        /// Deletes a single <see cref="IProductVariant"/>
        /// </summary>
        /// <param name="productVariant">The <see cref="IProductVariant"/> to be deleted</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Delete(IProductVariant productVariant, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs<IProductVariant>(productVariant), this))
                {
                    ((ProductVariant)productVariant).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateProductVariantRepository(uow))
                {
                    repository.Delete(productVariant);
                    uow.Commit();
                }
            }
            if (raiseEvents) Deleted.RaiseEvent(new DeleteEventArgs<IProductVariant>(productVariant), this);
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:27,代码来源:ProductVariantService.cs

示例13: GetProductVariant

		/// <summary>
		/// Gets the product variant.
		/// </summary>
		/// <param name="variant">The variant.</param>
		/// <param name="storeAlias">The store alias.</param>
		/// <param name="currencyCode">The currency code.</param>
		/// <returns></returns>
		/// <exception cref="System.ArgumentNullException">variant</exception>
		public static IProductVariant GetProductVariant(IProductVariant variant, string storeAlias = null, string currencyCode = null)
		{
			if (variant == null) throw new ArgumentNullException("variant");
			return GetProductVariant(variant.Id, storeAlias, currencyCode);
		}
开发者ID:Chuhukon,项目名称:uWebshop-Releases,代码行数:13,代码来源:Catalog.cs

示例14: ToProductVariant

        internal static IProductVariant ToProductVariant(this ProductVariantDisplay productVariantDisplay, IProductVariant destination)
        {
            if (productVariantDisplay.Key != Guid.Empty)
            {
                destination.Key = productVariantDisplay.Key;
            }
            if( !String.IsNullOrEmpty(productVariantDisplay.Name) )
            {
                destination.Name = productVariantDisplay.Name;
            }
            if( !String.IsNullOrEmpty(productVariantDisplay.Sku) )
            {
                destination.Sku = productVariantDisplay.Sku;
            }
            destination.Price = productVariantDisplay.Price;
            destination.CostOfGoods = productVariantDisplay.CostOfGoods;
            destination.SalePrice = productVariantDisplay.SalePrice;
            destination.OnSale = productVariantDisplay.OnSale;
            destination.Manufacturer = productVariantDisplay.Manufacturer;
            destination.ManufacturerModelNumber = productVariantDisplay.ManufacturerModelNumber;
            destination.Weight = productVariantDisplay.Weight;
            destination.Length = productVariantDisplay.Length;
            destination.Width = productVariantDisplay.Width;
            destination.Height = productVariantDisplay.Height;
            destination.Barcode = productVariantDisplay.Barcode;
            destination.Available = productVariantDisplay.Available;
            destination.TrackInventory = productVariantDisplay.TrackInventory;
            destination.OutOfStockPurchase = productVariantDisplay.OutOfStockPurchase;
            destination.Taxable = productVariantDisplay.Taxable;
            destination.Shippable = productVariantDisplay.Shippable;
            destination.Download = productVariantDisplay.Download;
            destination.DownloadMediaId = productVariantDisplay.DownloadMediaId;

            destination.ProductKey = productVariantDisplay.ProductKey;

            // We need to refactor the CatalogInventories to not be immutable if we are
            // going to need to do operations like this.  In the UI, the user "unchecks" a catalog that was
            // previously checked - so we need to remove it.
            var deletedCatalogKeys =
                destination.CatalogInventories.Where(
                    x => !productVariantDisplay.CatalogInventories.Select(ci => ci.CatalogKey).Contains(x.CatalogKey)).Select(x => x.CatalogKey).ToArray();
            foreach (var deletedCatalogKey in deletedCatalogKeys)
            {
                destination.RemoveFromCatalogInventory(deletedCatalogKey);
            }

            foreach (var catalogInventory in productVariantDisplay.CatalogInventories)
            {
                var catInv = destination.CatalogInventories.FirstOrDefault(x => x.CatalogKey == catalogInventory.CatalogKey);

                if (catInv != null)
                {
                    var destinationCatalogInventory = catInv;

                    destinationCatalogInventory = catalogInventory.ToCatalogInventory(destinationCatalogInventory);
                }
                else if (!Guid.Empty.Equals(catalogInventory.CatalogKey) && destination.HasIdentity)
                {
                    //// Add to a new catalog
                    destination.AddToCatalogInventory(catalogInventory.CatalogKey);
                }
            }

            foreach (var attribute in productVariantDisplay.Attributes)
            {
                IProductAttribute destinationProductAttribute;

                var attr = destination.Attributes.FirstOrDefault(x => x.Key == attribute.Key);
                if (attr != null)
                {
                    destinationProductAttribute = attr;

                    destinationProductAttribute = attribute.ToProductAttribute(destinationProductAttribute);
                }
                else
                {
                    destinationProductAttribute = new ProductAttribute(attribute.Name, attribute.Sku);

                    destinationProductAttribute = attribute.ToProductAttribute(destinationProductAttribute);

                    ProductAttributeCollection variantAttributes = destination.Attributes as ProductAttributeCollection;
                    variantAttributes.Add(destinationProductAttribute);
                }
            }

            destination.AddOrUpdateDetachedContent(productVariantDisplay);

            return destination;
        }
开发者ID:EricMunn,项目名称:Merchello,代码行数:89,代码来源:ProductDisplayExtensions.cs

示例15: IndexProductVariant

 private static void IndexProductVariant(IProductVariant productVariant)
 {
     ProductIndexer.ReIndexNode(productVariant.SerializeToXml().Root, IndexTypes.ProductVariant);
 }
开发者ID:VDBBjorn,项目名称:Merchello,代码行数:4,代码来源:ExamineEvents.cs


注:本文中的IProductVariant类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。