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)); }
public coreModel.Store Create(coreModel.Store store) { var dbStore = store.ToDataModel(); using (var repository = _repositoryFactory()) { repository.Add(dbStore); CommitChanges(repository); } //Need add seo separately if (store.SeoInfos != null) { foreach (var seoInfo in store.SeoInfos) { seoInfo.ObjectId = dbStore.Id; seoInfo.ObjectType = typeof(coreModel.Store).Name; _commerceService.UpsertSeo(seoInfo); } } //Deep save settings SaveObjectSettings(_settingManager, store); var retVal = GetById(store.Id); return(retVal); }
public coreModel.Store Create(coreModel.Store store) { var dbStore = store.ToDataModel(); using (var repository = _repositoryFactory()) { repository.Add(dbStore); CommitChanges(repository); } //Need add seo separately if (store.SeoInfos != null) { foreach (var seoInfo in store.SeoInfos) { seoInfo.ObjectId = dbStore.Id; seoInfo.ObjectType = typeof(coreModel.Store).Name; _commerceService.UpsertSeo(seoInfo); } } //Deep save properties _dynamicPropertyService.SaveDynamicPropertyValues(store); //Deep save settings _settingManager.SaveEntitySettingsValues(store); //Reset cache var cacheKey = CacheKey.Create("StoreModule", "GetById", store.Id); _cacheManager.Remove(cacheKey); var retVal = GetById(store.Id); return(retVal); }
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.MainProduct = item; 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); }