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


C# Catalog.Model类代码示例

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


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

示例1: Create

  public void Create(coreModel.CatalogProduct[] items)
  {
      var pkMap = new PrimaryKeyResolvingMap();
      using (var repository = _catalogRepositoryFactory())
      {
          foreach (var item in items)
          {
              var dbItem = item.ToDataModel(pkMap);
              repository.Add(dbItem);
              if (item.Variations != null)
              {
                  foreach (var variation in item.Variations)
                  {
                      variation.MainProductId = dbItem.Id;
                      variation.CatalogId = dbItem.CatalogId;
                      var dbVariation = variation.ToDataModel(pkMap);
                      repository.Add(dbVariation);
                  }
              }
          }
          CommitChanges(repository);
          pkMap.ResolvePrimaryKeys();
      }
 
      //Update SEO 
      var itemsWithVariations = items.Concat(items.Where(x => x.Variations != null).SelectMany(x => x.Variations)).ToArray();
      _commerceService.UpsertSeoForObjects(itemsWithVariations);
  }
开发者ID:adwardliu,项目名称:vc-community,代码行数:28,代码来源:ItemServiceImpl.cs

示例2: Create

        public coreModel.Category Create(coreModel.Category category)
        {
            if (category == null)
                throw new ArgumentNullException("category");

            var dbCategory = category.ToDataModel();
            
            using (var repository = _catalogRepositoryFactory())
            {	
                repository.Add(dbCategory);
                CommitChanges(repository);
            }
			//Need add seo separately
			if (category.SeoInfos != null)
			{
				foreach (var seoInfo in category.SeoInfos)
				{
					seoInfo.ObjectId = dbCategory.Id;
					seoInfo.ObjectType = typeof(coreModel.Category).Name;
					_commerceService.UpsertSeo(seoInfo);
				}
			}
			category.Id = dbCategory.Id;
            return GetById(dbCategory.Id);
        }
开发者ID:alt-soft,项目名称:vc-community,代码行数:25,代码来源:CategoryServiceImpl.cs

示例3: Create

		public coreModel.Property Create(coreModel.Property property)
		{
			if (property.CatalogId == null)
			{
				throw new NullReferenceException("property.CatalogId");
			}
		
			var dbProperty = property.ToDataModel();
			using (var repository = _catalogRepositoryFactory())
			{
				if (property.CategoryId != null)
				{
					var dbCategory = repository.GetCategoryById(property.CategoryId);
					repository.SetCategoryProperty(dbCategory, dbProperty);
				}
				else
				{
					var dbCatalog = repository.GetCatalogById(property.CatalogId) as dataModel.Catalog;
					if(dbCatalog == null)
					{
						throw new OperationCanceledException("Add property only to catalog");
					}
					repository.SetCatalogProperty(dbCatalog, dbProperty);
				}
				repository.Add(dbProperty);
				CommitChanges(repository);
			}
			var retVal = GetById(dbProperty.Id);
			return retVal;
		}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:30,代码来源:PropertyServiceImpl.cs

示例4: ToWebModel

		public static webModel.Pricelist ToWebModel(this coreModel.Pricelist priceList, coreCatalogModel.CatalogProduct[] products = null, coreCatalogModel.Catalog[] catalogs = null, ConditionExpressionTree etalonEpressionTree = null)
		{
			var retVal = new webModel.Pricelist();
			retVal.InjectFrom(priceList);
			retVal.Currency = priceList.Currency;
			if (priceList.Prices != null)
			{
				retVal.ProductPrices = new List<webModel.ProductPrice>();
				foreach(var group in priceList.Prices.GroupBy(x=>x.ProductId))
				{
					var productPrice = new webModel.ProductPrice(group.Key, group.Select(x=> x.ToWebModel()));
					
					retVal.ProductPrices.Add(productPrice);
					if (products != null)
					{
						var product = products.FirstOrDefault(x => x.Id == productPrice.ProductId);
						if(product != null)
						{
							productPrice.ProductName = product.Name;
						}
					}
				}
				
			}
			if(priceList.Assignments != null)
			{
				retVal.Assignments = priceList.Assignments.Select(x => x.ToWebModel(catalogs, etalonEpressionTree)).ToList();
			}
			return retVal;
		}
开发者ID:adwardliu,项目名称:vc-community,代码行数:30,代码来源:PriceListConverter.cs

示例5: ToGoogleModel

        public static googleModel.Product ToGoogleModel(this moduleModel.CatalogProduct product, IBlobUrlResolver assetUrlResolver, moduleModel.Property[] properties = null)
        {
            var retVal = new googleModel.Product();
            retVal.InjectFrom(product);
            var langCode = product.Catalog.Languages.First().LanguageCode;

            retVal.Link = @"http://virtocommerce-test.azurewebsites.net/";

            retVal.OfferId = product.Id;
            retVal.Title = product.Name;
            retVal.Description = product.Reviews.Any() ? product.Reviews.First(x => x.LanguageCode == langCode).Content : product.Name;
            retVal.Link = @"http://virtocommerce-test.azurewebsites.net/";
            retVal.ImageLink = assetUrlResolver.GetAbsoluteUrl(product.Assets.First().Url).TrimStart('/');
            retVal.ContentLanguage = langCode;
            retVal.TargetCountry = "US";
            retVal.Channel = "online";
            retVal.Availability = "in stock";
            retVal.Condition = "new";
            retVal.GoogleProductCategory = "Media > Books";
            retVal.Gtin = "9780007350896";
            retVal.Taxes = new[] { new googleModel.ProductTax { Country = "US", Rate = 10, Region = "CA" } };
            retVal.Shipping = new[]
            {
                new googleModel.ProductShipping
                {
                    Country = "US",
                    Price = new googleModel.Price { Currency = "USD", Value = "5"}
                }
            };

            return retVal;
        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:32,代码来源:ProductConverter.cs

示例6: GetByIds

        public coreModel.Category[] GetByIds(string[] categoryIds, coreModel.CategoryResponseGroup responseGroup, string catalogId = null)
        {
            coreModel.Category[] result;

            using (var repository = _catalogRepositoryFactory())
            {
                result = repository.GetCategoriesByIds(categoryIds, responseGroup)
                    .Select(c => c.ToCoreModel())
                    .ToArray();
            }

            // Fill outlines for products
            if (responseGroup.HasFlag(coreModel.CategoryResponseGroup.WithOutlines))
            {
                _outlineService.FillOutlinesForObjects(result, catalogId);
            }

            // Fill SEO info
            if ((responseGroup & coreModel.CategoryResponseGroup.WithSeo) == coreModel.CategoryResponseGroup.WithSeo)
            {
                var objectsWithSeo = new List<ISeoSupport>(result);

                var outlineItems = result
                    .Where(c => c.Outlines != null)
                    .SelectMany(c => c.Outlines.SelectMany(o => o.Items));
                objectsWithSeo.AddRange(outlineItems);

                _commerceService.LoadSeoForObjects(objectsWithSeo.ToArray());
            }

            return result;
        }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:32,代码来源:CategoryServiceImpl.cs

示例7: ToAmazonModel

        //initial version of product converter to amazon product.
        //it should be adopted to the particular customer needs as many Amazon properties (like category) are unique and can't be mapped automatically.
        public static Product ToAmazonModel(this moduleModel.CatalogProduct product, IBlobUrlResolver assetUrlResolver, moduleModel.Property[] properties = null)
        {
            var amazonProduct = new Product();
            amazonProduct.InjectFrom(product);

            amazonProduct.DescriptionData = new ProductDescriptionData
            {
                Brand = "Brand",
                Description = "Product description",

            };

            amazonProduct.Condition = new ConditionInfo { ConditionType = ConditionType.New };
            if (product.Images != null && product.Images.Any())
                amazonProduct.ExternalProductUrl = assetUrlResolver.GetAbsoluteUrl(product.Images.First().Url.TrimStart('/'));
            amazonProduct.SKU = product.Code;
            amazonProduct.StandardProductID = new StandardProductID { Value = amazonProduct.SKU, Type = StandardProductIDType.ASIN };

            //var mainCat = new Home();
            //var subCat = new Kitchen();
            //mainCat.ProductType = new HomeProductType { Item = subCat };

            //amazonProduct.ProductData = new ProductProductData { Item = mainCat };

            return amazonProduct;
        }        
开发者ID:adwardliu,项目名称:vc-community,代码行数:28,代码来源:ProductConverter.cs

示例8: Create

        public coreModel.Property Create(coreModel.Property property)
        {
            if (property.CatalogId == null)
            {
                throw new NullReferenceException("property.CatalogId");
            }

            var dbProperty = property.ToDataModel();
            using (var repository = _catalogRepositoryFactory())
            {
                if (property.CategoryId != null)
                {
                    var dbCategory = repository.GetCategoriesByIds(new[] { property.CategoryId }, coreModel.CategoryResponseGroup.Info).FirstOrDefault();
                    if (dbCategory == null)
                    {
                        throw new NullReferenceException("dbCategory");
                    }
                    dbCategory.Properties.Add(dbProperty);
                }
                else
                {
                    var dbCatalog = repository.GetCatalogById(property.CatalogId);
                    if (dbCatalog == null)
                    {
                        throw new NullReferenceException("dbCatalog");
                    }
                    dbCatalog.Properties.Add(dbProperty);
                }
                repository.Add(dbProperty);
                CommitChanges(repository);
            }
            var retVal = GetById(dbProperty.Id);
            return retVal;
        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:34,代码来源:PropertyServiceImpl.cs

示例9: Search

        private IEnumerable<moduleModel.CatalogProduct> Search(CatalogIndexedSearchCriteria criteria, out CatalogItemSearchResults results, moduleModel.ItemResponseGroup responseGroup)
        {
            var items = new List<moduleModel.CatalogProduct>();
            var itemsOrderedList = new List<string>();

            var foundItemCount = 0;
            var dbItemCount = 0;
            var searchRetry = 0;

            //var myCriteria = criteria.Clone();
            var myCriteria = criteria;

            do
            {
                // Search using criteria, it will only return IDs of the items
                var scope = _searchConnection.Scope;
                var searchResults = _searchProvider.Search(scope, criteria) as SearchResults;
                var itemKeyValues = searchResults.GetKeyAndOutlineFieldValueMap<string>();
                results = new CatalogItemSearchResults(myCriteria, itemKeyValues, searchResults);

                searchRetry++;

                if (results.Items == null)
                {
                    continue;
                }

                //Get only new found itemIds
                var uniqueKeys = results.Items.Keys.Except(itemsOrderedList).ToArray();
                foundItemCount = uniqueKeys.Length;

                if (!results.Items.Any())
                {
                    continue;
                }

                itemsOrderedList.AddRange(uniqueKeys);

                // Now load items from repository
                var currentItems = _itemService.GetByIds(uniqueKeys.ToArray(), responseGroup);

                var orderedList = currentItems.OrderBy(i => itemsOrderedList.IndexOf(i.Id));
                items.AddRange(orderedList);
                dbItemCount = currentItems.Length;

                //If some items where removed and search is out of sync try getting extra items
                if (foundItemCount > dbItemCount)
                {
                    //Retrieve more items to fill missing gap
                    myCriteria.RecordsToRetrieve += (foundItemCount - dbItemCount);
                }
            }
            while (foundItemCount > dbItemCount && results.Items.Any() && searchRetry <= 3 &&
                (myCriteria.RecordsToRetrieve + myCriteria.StartingRecord) < results.TotalCount);

            return items;
        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:57,代码来源:ItemBrowsingService.cs

示例10: ToCoreModel

		/// <summary>
		/// Converting to model type
		/// </summary>
		/// <param name="catalogBase"></param>
		/// <returns></returns>
		public static coreModel.CatalogLanguage ToCoreModel(this dataModel.CatalogLanguage dbLanguage, coreModel.Catalog catalog)
		{
			var retVal = new coreModel.CatalogLanguage();
			retVal.InjectFrom(dbLanguage);

			retVal.CatalogId = catalog.Id;
			retVal.LanguageCode = dbLanguage.Language;

			return retVal;
		}
开发者ID:adwardliu,项目名称:vc-community,代码行数:15,代码来源:CatalogLanguageConverter.cs

示例11: Property

		/// <summary>
		/// Create property meta information from property value
		/// </summary>
		/// <param name="propValue"></param>
		/// <param name="catalogId"></param>
		/// <param name="categoryId"></param>
		/// <param name="propertyType"></param>
		public Property(PropertyValue propValue, string catalogId, string categoryId, coreModel.PropertyType propertyType)
		{
			Id = propValue.Id;
			CatalogId = catalogId;
			IsManageable = false;
			Name = propValue.PropertyName;
			Type = propertyType;
			ValueType = propValue.ValueType;
			Values = new List<PropertyValue>();
		}
开发者ID:adwardliu,项目名称:vc-community,代码行数:17,代码来源:Property.cs

示例12: ToWebModel

		public static webModel.Category ToWebModel(this moduleModel.Category category, IBlobUrlResolver blobUrlResolver = null, moduleModel.Property[] properties = null)
		{
			var retVal = new webModel.Category();
			retVal.InjectFrom(category);
			retVal.Catalog = category.Catalog.ToWebModel();
			retVal.SeoInfos = category.SeoInfos;
	
			if(category.Parents != null)
			{
				retVal.Parents = category.Parents.ToDictionary(x => x.Id, x => x.Name);
			}
			//For virtual category links not needed
			if (!category.Virtual && category.Links != null)
			{
				retVal.Links = category.Links.Select(x => x.ToWebModel()).ToList();
			}
			retVal.Properties = new List<webModel.Property>();
			//Need add property for each meta info
			if (properties != null)
			{
				retVal.Properties = new List<webModel.Property>();
				foreach (var property in properties)
				{
					var webModelProperty = property.ToWebModel();
					webModelProperty.Values = new List<webModel.PropertyValue>();
					webModelProperty.IsManageable = true;
					webModelProperty.IsReadOnly = property.Type != moduleModel.PropertyType.Category;
					retVal.Properties.Add(webModelProperty);
				}
			}

			//Populate property values
			if (category.PropertyValues != null)
			{
				foreach (var propValue in category.PropertyValues.Select(x => x.ToWebModel()))
				{
					var property = retVal.Properties.FirstOrDefault(x => x.IsSuitableForValue(propValue));
					if (property == null)
					{
						//Need add dummy property for each value without property
						property = new webModel.Property(propValue, category.CatalogId, category.Id, moduleModel.PropertyType.Category);
						retVal.Properties.Add(property);
					}
					property.Values.Add(propValue);
				}
			}

			if (category.Images != null)
			{
				retVal.Images = category.Images.Select(x => x.ToWebModel(blobUrlResolver)).ToList();
			}
			return retVal;
		}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:53,代码来源:CategoryConverter.cs

示例13: Create

		public coreModel.Catalog Create(coreModel.Catalog catalog)
		{
			var dbCatalog = catalog.ToDataModel();
			coreModel.Catalog retVal = null;
			using (var repository = _catalogRepositoryFactory())
			{
				repository.Add(dbCatalog);
				CommitChanges(repository);
			}
			retVal = GetById(dbCatalog.Id);
			return retVal;
		}
开发者ID:nisarzahid,项目名称:vc-community,代码行数:12,代码来源:CatalogServiceImpl.cs

示例14: ListItemsSearch

        public IHttpActionResult ListItemsSearch(coreModel.SearchCriteria searchCriteria)
        {
            ApplyRestrictionsForCurrentUser(searchCriteria);

            searchCriteria.WithHidden = true;
            //Need search in children categories if user specify keyword
            if (!string.IsNullOrEmpty(searchCriteria.Keyword))
            {
                searchCriteria.SearchInChildren = true;
                searchCriteria.SearchInVariations = true;
            }

            var retVal = new webModel.ListEntrySearchResult();

            int categorySkip = 0;
            int categoryTake = 0;
            //Because products and categories represent in search result as two separated collections for handle paging request 
            //we should join two resulting collection artificially
            //search categories
            if ((searchCriteria.ResponseGroup & coreModel.SearchResponseGroup.WithCategories) == coreModel.SearchResponseGroup.WithCategories)
            {
                searchCriteria.ResponseGroup = searchCriteria.ResponseGroup & ~coreModel.SearchResponseGroup.WithProducts;
                var categoriesSearchResult = _searchService.Search(searchCriteria);
                var categoriesTotalCount = categoriesSearchResult.Categories.Count();

                categorySkip = Math.Min(categoriesTotalCount, searchCriteria.Skip);
                categoryTake = Math.Min(searchCriteria.Take, Math.Max(0, categoriesTotalCount - searchCriteria.Skip));
                var categories = categoriesSearchResult.Categories.Skip(categorySkip).Take(categoryTake).Select(x => new webModel.ListEntryCategory(x.ToWebModel(_blobUrlResolver))).ToList();

                retVal.TotalCount = categoriesTotalCount;
                retVal.ListEntries.AddRange(categories);

                searchCriteria.ResponseGroup = searchCriteria.ResponseGroup | coreModel.SearchResponseGroup.WithProducts;
            }

            //search products
            if ((searchCriteria.ResponseGroup & coreModel.SearchResponseGroup.WithProducts) == coreModel.SearchResponseGroup.WithProducts)
            {
                searchCriteria.ResponseGroup = searchCriteria.ResponseGroup & ~coreModel.SearchResponseGroup.WithCategories;
                searchCriteria.Skip = searchCriteria.Skip - categorySkip;
                searchCriteria.Take = searchCriteria.Take - categoryTake;
                var productsSearchResult = _searchService.Search(searchCriteria);

                var products = productsSearchResult.Products.Select(x => new webModel.ListEntryProduct(x.ToWebModel(_blobUrlResolver)));

                retVal.TotalCount += productsSearchResult.ProductsTotalCount;
                retVal.ListEntries.AddRange(products);
            }


            return Ok(retVal);
        }
开发者ID:sameerkattel,项目名称:vc-community,代码行数:52,代码来源:CatalogModuleListEntryController.cs

示例15: GetByIds

		public coreModel.CatalogProduct[] GetByIds(string[] itemIds, coreModel.ItemResponseGroup respGroup)
		{
			// TODO: Optimize performance (Sasha)
			// 1. Catalog should be cached and not retrieved every time from the db
			// 2. SEO info can be retrieved for all items at once instead of one by one
			// 3. Optimize how main variation is loaded
			// 4. Associations shouldn't be loaded always and must be optimized as well
			// 5. No need to get properties meta data to just retrieve property ID
			var retVal = new List<coreModel.CatalogProduct>();
			using (var repository = _catalogRepositoryFactory())
			{
				var dbItems = repository.GetItemByIds(itemIds, respGroup);

				SeoInfo[] seoInfos = null;
				if ((respGroup & coreModel.ItemResponseGroup.Seo) == coreModel.ItemResponseGroup.Seo)
				{
					seoInfos = _commerceService.GetObjectsSeo(dbItems.Select(x => x.Id).ToArray()).ToArray();
				}

				var categoriesIds = dbItems.SelectMany(x => x.CategoryLinks).Select(x => x.CategoryId).Distinct().ToArray();
				var dbCategories = repository.GetCategoriesByIds(categoriesIds);
				foreach (var dbItem in dbItems)
				{
					var associatedProducts = new List<coreModel.CatalogProduct>();
					if ((respGroup & coreModel.ItemResponseGroup.ItemAssociations) == coreModel.ItemResponseGroup.ItemAssociations)
					{
						if (dbItem.AssociationGroups.Any())
						{
							foreach (var association in dbItem.AssociationGroups.SelectMany(x => x.Associations))
							{
								var associatedProduct = GetById(association.ItemId, coreModel.ItemResponseGroup.ItemAssets);
								associatedProducts.Add(associatedProduct);
							}
						}
					}
					var dbCatalog = repository.GetCatalogById(dbItem.CatalogId);

					var catalog = dbCatalog.ToCoreModel();
					coreModel.Category category = null;
					if (dbItem.Category != null)
					{
						category = dbItem.Category.ToCoreModel(catalog);
					}

					var item = dbItem.ToCoreModel(catalog: catalog, category: category, associatedProducts: associatedProducts.ToArray());
					item.SeoInfos = seoInfos != null ? seoInfos.Where(x => x.ObjectId == dbItem.Id).ToList() : null;
					retVal.Add(item);
				}
			}

			return retVal.ToArray();
		}
开发者ID:tuyndv,项目名称:vc-community,代码行数:52,代码来源:ItemServiceImpl.cs


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