本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}