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


C# VirtoCommerce.Domain.Catalog.Model.ToDataModel方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: Create

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

示例5: Create

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

            var pkMap = new PrimaryKeyResolvingMap();
            var dbCategory = category.ToDataModel(pkMap);
            
            using (var repository = _catalogRepositoryFactory())
            {	
                repository.Add(dbCategory);
                CommitChanges(repository);
                pkMap.ResolvePrimaryKeys();
            }
            //Need add seo separately
            _commerceService.UpsertSeoForObjects(new[] { category });
            return GetById(dbCategory.Id, Domain.Catalog.Model.CategoryResponseGroup.Info);
        }
开发者ID:adwardliu,项目名称:vc-community,代码行数:18,代码来源:CategoryServiceImpl.cs

示例6: Create

		public coreModel.CatalogProduct Create(coreModel.CatalogProduct item)
		{
			var dbItem = item.ToDataModel();

			using (var repository = _catalogRepositoryFactory())
			{
				repository.Add(dbItem);
				item.Id = dbItem.Id;

				if (item.Variations != null)
				{
					foreach (var variation in item.Variations)
					{
						variation.MainProductId = dbItem.Id;
						variation.CatalogId = dbItem.CatalogId;
						var dbVariation = variation.ToDataModel();
						repository.Add(dbVariation);
						variation.Id = dbVariation.Id;
					}
				}

				CommitChanges(repository);
			}

			//Need add seo separately
			if (item.SeoInfos != null)
			{
				foreach (var seoInfo in item.SeoInfos)
				{
					seoInfo.ObjectId = dbItem.Id;
					seoInfo.ObjectType = typeof(coreModel.CatalogProduct).Name;
					_commerceService.UpsertSeo(seoInfo);
				}
			}

			if (item.Variations != null)
			{
				foreach (var variation in item.Variations)
				{
					if (variation.SeoInfos != null)
					{
						foreach (var seoInfo in variation.SeoInfos)
						{
							seoInfo.ObjectId = variation.Id;
							seoInfo.ObjectType = typeof(coreModel.CatalogProduct).Name;
							_commerceService.UpsertSeo(seoInfo);
						}
					}
				}
			}

			var retVal = GetById(dbItem.Id, coreModel.ItemResponseGroup.ItemLarge);
			return retVal;
		}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:54,代码来源:ItemServiceImpl.cs

示例7: 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


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