private async Task Export(IEnumerable <string> dataTypes) { IEnumerable <IDataTypeDefinition> dataTypeDefinitions; if (dataTypes.Any()) { var ids = dataTypes.Select(int.Parse); dataTypeDefinitions = dataTypeService.GetAllDataTypeDefinitions(ids.ToArray()); } else { dataTypeDefinitions = dataTypeService.GetAllDataTypeDefinitions(); } if (!settings.TryGetChauffeurDirectory(out string exportDirectory)) { return; } var xml = new XDocument(); xml.Add(packagingService.Export(dataTypeDefinitions, false)); var fileName = DateTime.UtcNow.ToString("yyyyMMdd") + "-data-type-definitions.xml"; fileSystem.File.WriteAllText(fileSystem.Path.Combine(exportDirectory, fileName), xml.ToString()); await Out.WriteLineFormattedAsync("Data Type Definitions have been exported with file name '{0}'", fileName); }
public override IEnumerable <HealthCheckStatus> GetStatus() { var obsoleteFound = false; var dataTypes = _dataTypeService.GetAllDataTypeDefinitions(); foreach (var dataType in dataTypes) { if (_obsoleteDataTypes.Select(d => d.Alias).Contains(dataType.PropertyEditorAlias)) { var obsolete = _obsoleteDataTypes.First(d => d.Alias == dataType.PropertyEditorAlias); obsoleteFound = true; yield return(new HealthCheckStatus($"{dataType.Name} is using obsolete data type {dataType.PropertyEditorAlias}") { ResultType = StatusResultType.Warning, Actions = Actions(dataType, obsolete) }); } } if (!obsoleteFound) { yield return(new HealthCheckStatus("No obsolete data types found") { ResultType = StatusResultType.Success }); } }
public DataTypeModule(IDataTypeService service) { _service = service; _locks = new SyncLock <MemberInfo>(); _allDataTypeDefinitions = new Lazy <IEnumerable <IDataTypeDefinition> >(() => { return(_service.GetAllDataTypeDefinitions()); }); }
public void Delete() { var dataTypeDefinition = DataTypeService.GetAllDataTypeDefinitions().FirstOrDefault(x => x.Name == DataTypeDefinition.Name); if (dataTypeDefinition == null) { throw new FluentException(string.Format("The Data Type Definition `{0}` does not exist.", DataTypeDefinition.Name)); } UmbracoDatabase.Delete <DataTypePreValueDto>("WHERE datatypeNodeId = @NodeId", new { NodeId = DataTypeDefinition.Id }); DataTypeService.Delete(dataTypeDefinition); }
private int?CreateDataType(Item item, int parentId, int userId = 0) { var dataType = new DataTypeDefinition(parentId, "Umbraco.ContentPicker2"); dataType.Name = item.Name; //need to create content in order to select start node var ttt = _dataTypeService.GetAllDataTypeDefinitions(); _dataTypeService.Save(dataType); return(dataType.Id); }
private async System.Threading.Tasks.Task CreatePackage(StreamWriter deliveryFileStream, string name) { var contentTypes = GetEntityChanges(_contentTypeService.GetAllContentTypes(), EntityType.CONTENT_TYPE); var dataTypes = GetEntityChanges(_dataTypeService.GetAllDataTypeDefinitions(), EntityType.DATA_TYPE); var templates = GetFileChanges(_fileService.GetTemplates(), EntityType.TEMPLATE); var styleSheets = GetFileChanges(_fileService.GetStylesheets(), EntityType.STYLESHEET); var macros = GetChangedMacros(); var packageXml = new XDocument(); packageXml.Add( new XElement( "umbPackage", new XElement( "DocumentTypes", contentTypes.Select(ct => _packagingService.Export(ct, false)) ), _packagingService.Export(dataTypes, false), _packagingService.Export(templates, false), _packagingService.Export(macros, false), new XElement( "Stylesheets", styleSheets.Select(s => new XElement( "Stylesheet", new XElement("Name", s.Alias), new XElement("FileName", s.Name), new XElement("Content", new XCData(s.Content)), new XElement( "Properties", s.Properties.Select(p => new XElement( "Property", new XElement("Name", p.Name), new XElement("Alias", p.Alias), new XElement("Value", p.Value) ) ) ) ) ) ) ) ); _settings.TryGetChauffeurDirectory(out string dir); _fileSystem.File.WriteAllText(_fileSystem.Path.Combine(dir, $"{name}.xml"), packageXml.ToString()); await deliveryFileStream.WriteLineAsync($"package {name}"); _database.TruncateTable("Chauffeur_Changes"); }
public static bool DataTypeChanged(XElement node) { string filehash = XmlDoc.GetPreCalculatedHash(node); if (string.IsNullOrEmpty(filehash)) { return(true); } var dataTypeDefinitionId = new Guid(node.Attribute("Definition").Value); XAttribute defId = node.Attribute("Definition"); if (defId == null) { return(true); } /* * //var _dataTypeService = ApplicationContext.Current.Services.DataTypeService; * var item = _dataTypeService.GetDataTypeDefinitionById(new Guid(defId.Value)); */ if (_dataTypes == null) { // speed test, calling data types seems slow, // so we load all them at once, then refrence this when doing the compares. // this is a little bit faster than calling each one as we go through... _dataTypes = new Dictionary <Guid, IDataTypeDefinition>(); foreach (IDataTypeDefinition dtype in _dataTypeService.GetAllDataTypeDefinitions()) { _dataTypes.Add(dtype.Key, dtype); } } Guid defGuid = new Guid(defId.Value); if (!_dataTypes.ContainsKey(defGuid)) { return(true); } //var packagingService = ApplicationContext.Current.Services.PackagingService; XElement export = _packagingService.Export(_dataTypes[defGuid], false); string dbMD5 = XmlDoc.CalculateMD5Hash(export, true); // LogHelper.Info<uSync>("XML File (we just got to hash from) {0}", () => export.ToString()); // LogHelper.Info<uSync>("File {0} : Guid {1}", () => filehash, () => dbMD5); return(!filehash.Equals(dbMD5)); }
private async Task CreatePackage(StreamWriter deliveryFileStream, string name) { var contentTypes = contentTypeService.GetAllContentTypes(); var dataTypes = dataTypeService.GetAllDataTypeDefinitions(); var templates = fileService.GetTemplates(); var styleSheets = fileService.GetStylesheets(); var macros = macroService.GetAll(); var packageXml = new XDocument(); packageXml.Add( new XElement( "umbPackage", new XElement( "DocumentTypes", contentTypes.Select(ct => packagingService.Export(ct, false)) ), packagingService.Export(dataTypes, false), packagingService.Export(templates, false), packagingService.Export(macros, false), new XElement( "Stylesheets", styleSheets.Select(s => new XElement( "Stylesheet", new XElement("Name", s.Alias), new XElement("FileName", s.Name), new XElement("Content", new XCData(s.Content)), new XElement( "Properties", s.Properties.Select(p => new XElement( "Property", new XElement("Name", p.Name), new XElement("Alias", p.Alias), new XElement("Value", p.Value) ) ) ) ) ) ) ) ); settings.TryGetChauffeurDirectory(out string dir); fileSystem.File.WriteAllText(fileSystem.Path.Combine(dir, $"{name}.xml"), packageXml.ToString()); await deliveryFileStream.WriteLineAsync($"package {name}"); }
/// <summary> /// Synchronizes this instance. /// </summary> public void Run() { var models = _typeResolver.DataTypes.ToArray(); if (!models.Any()) { return; } new DataTypeValidator().Validate(models); var dataTypes = _dataTypeService.GetAllDataTypeDefinitions().ToArray(); foreach (var model in models) { Synchronize(dataTypes, model); } }
public override IEnumerable <HealthCheckStatus> GetStatus() { var foundDataTypes = new List <int>(); var contentTypes = _contentTypeService.GetAllContentTypes(); foreach (var contentType in contentTypes) { foundDataTypes.AddRange(contentType.PropertyTypes.Select(p => p.DataTypeDefinitionId)); foundDataTypes.AddRange(contentType.NoGroupPropertyTypes.Select(p => p.DataTypeDefinitionId)); foundDataTypes.AddRange(contentType.CompositionPropertyTypes.Select(p => p.DataTypeDefinitionId)); } var mediaTypes = _contentTypeService.GetAllMediaTypes(); foreach (var mediaType in mediaTypes) { foundDataTypes.AddRange(mediaType.PropertyTypes.Select(p => p.DataTypeDefinitionId)); foundDataTypes.AddRange(mediaType.NoGroupPropertyTypes.Select(p => p.DataTypeDefinitionId)); foundDataTypes.AddRange(mediaType.CompositionPropertyTypes.Select(p => p.DataTypeDefinitionId)); } var unusedDataTypes = _dataTypeService.GetAllDataTypeDefinitions() .Where(d => !d.Name.StartsWith("List View -")) .Where(d => !foundDataTypes.Distinct().Contains(d.Id)) .ToArray(); if (!unusedDataTypes.Any()) { yield return(new HealthCheckStatus("No unused data types found") { ResultType = StatusResultType.Success }); } foreach (var dataType in unusedDataTypes) { yield return(new HealthCheckStatus($"{dataType.Name} does not appear to be used") { ResultType = StatusResultType.Warning }); } }
public ActionResult HandleIletisimFormPost(IletisimModel model) { var yeniKayit = Services.ContentService.CreateContent(model.Name + " " + model.Surname + " " + DateTime.Now.ToString("dd/MMM/yyyy HH:mm.ss"), CurrentPage.Id, "iletisimFormlari"); yeniKayit.SetValue("pageTitle", CurrentPage.Name); yeniKayit.SetValue("siteName", CurrentPage.Parent.Name); yeniKayit.SetValue("emailFrom", model.Email); yeniKayit.SetValue("nameFrom", model.Name); yeniKayit.SetValue("surnameFrom", model.Surname); yeniKayit.SetValue("phone", model.Phone); yeniKayit.SetValue("message", model.Message); IDataTypeService myService = ApplicationContext.Services.DataTypeService; var SecilenCinsiyet = myService.GetAllDataTypeDefinitions().First(x => x.Id == 1118); int SecilenCinsiyetPreValueId = myService.GetPreValuesCollectionByDataTypeId(SecilenCinsiyet.Id).PreValuesAsDictionary.Where(x => x.Value.Value == model.SecilenCinsiyet).Select(x => x.Value.Id).First(); yeniKayit.SetValue("cinsiyetSecimi", SecilenCinsiyetPreValueId); Services.ContentService.SaveAndPublishWithStatus(yeniKayit); return(RedirectToCurrentUmbracoPage()); }
private void PersistDataTypeAndPreValues(DataTypeRegistration dataTypeRegistration, IDataTypeDefinition dataTypeDefinition, IDictionary <string, PreValue> preValues) { CodeFirstManager.Current.Log("Saving data type " + dataTypeRegistration.DataTypeInstanceName, this); if (CodeFirstManager.Current.Features.InitialisationMode == InitialisationMode.Ensure) { throw new CodeFirstPassiveInitialisationException("The data types or prevalues defined in the database do not match the types passed in to initialise. In InitialisationMode.Ensure the types must match or the site will be prevented from starting."); } else if (CodeFirstManager.Current.Features.InitialisationMode == InitialisationMode.Sync) { UmbracoContext.EnsureContext(new HttpContextWrapper(new HttpContext(new HttpRequest("", "http://tempuri.org", ""), new HttpResponse(new StringWriter()))), ApplicationContext.Current, true); _service.SaveDataTypeAndPreValues(dataTypeDefinition, preValues); //reset the collection if we've modified a type _allDataTypeDefinitions = new Lazy <IEnumerable <IDataTypeDefinition> >(() => { return(_service.GetAllDataTypeDefinitions()); }); } else if (CodeFirstManager.Current.Features.InitialisationMode != InitialisationMode.Passive) { throw new CodeFirstException("Unknown initialisation mode"); } }
public void Transaction_Works() { Assert.AreEqual(24, dataTypeService.GetAllDataTypeDefinitions().Count()); }
private int GetPreValueId(IDataTypeService dts, string dataTypeName, string preValueText) { IDataTypeDefinition dataTypeDefinition = dts.GetAllDataTypeDefinitions().First <IDataTypeDefinition>((Func <IDataTypeDefinition, bool>)(x => x.Name == dataTypeName)); return(dts.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id).PreValuesAsDictionary.Where(d => d.Value.Value == preValueText).Select(f => f.Value.Id).First()); }
private IDataTypeDefinition GetDataTypeDefinition(string dataTypeName) { return(DataTypeService.GetAllDataTypeDefinitions().Single(x => x.Name.Equals(dataTypeName, StringComparison.InvariantCultureIgnoreCase))); }
public static bool DataTypeChanged(XElement node) { string fileHash = node.CalculateMD5Hash(true); if (string.IsNullOrWhiteSpace(fileHash)) { return(true); } XAttribute defId = node.Attribute("Definition"); if (defId == null) { return(true); } if (_dataTypeService == null) { _dataTypeService = ApplicationContext.Current.Services.DataTypeService; } if (_dataTypes == null) { // speed test - load all the datatypes once // less db ? it's about 1.8s faster with default datatypes // more so with more types? _dataTypes = new Dictionary <Guid, IDataTypeDefinition>(); foreach (var dtype in _dataTypeService.GetAllDataTypeDefinitions()) { _dataTypes.Add(dtype.Key, dtype); } } Guid defGuid = new Guid(defId.Value); if (!_dataTypes.ContainsKey(defGuid)) { return(true); } var item = _dataTypes[defGuid]; if (item == null) { return(true); } var uDt = new uSyncDataType(); var dbNode = uDt.Export(item); if (dbNode == null) { return(true); } string dbHash = dbNode.CalculateMD5Hash(true); LogHelper.Debug <ChangeTracker>("Comparing: [{0}] to [{1}]", () => fileHash, () => dbHash); return(!fileHash.Equals(dbHash)); }
public bool Execute(string packageName, XmlNode xmlData) { IMediaService mediaService = ApplicationContext.Current.Services.MediaService; IContentService contentService = UmbracoContext.Current.Application.Services.ContentService; IContentTypeService contentTypeService = ApplicationContext.Current.Services.ContentTypeService; IFileService fileService = ApplicationContext.Current.Services.FileService; //ApplicationContext.Current.Services.DataTypeService. IDataTypeService dataTypeService = UmbracoContext.Current.Application.Services.DataTypeService; #region Create media List <int> productImageIds = new List <int>(); List <IMedia> productImages = new List <IMedia>(); try { //Create image files const string productImagesFolderName = "Product images"; string[] mediaInstallImages = Directory.GetFiles(HostingEnvironment.MapPath("~/Assets/InstallMedia")); IMedia productImagesFolder = mediaService.GetByLevel(1).FirstOrDefault(m => m.Name == productImagesFolderName); if (productImagesFolder == null) { productImagesFolder = mediaService.CreateMedia(productImagesFolderName, -1, "Folder"); mediaService.Save(productImagesFolder); } if (!productImagesFolder.Children().Any()) { foreach (string mediaInstallImage in mediaInstallImages) { string fileName = Path.GetFileName(mediaInstallImage); IMedia productImage = mediaService.CreateMedia(fileName, productImagesFolder.Id, "Image"); byte[] buffer = File.ReadAllBytes(Path.GetFullPath(mediaInstallImage)); using (MemoryStream strm = new MemoryStream(buffer)) { productImage.SetValue("umbracoFile", fileName, strm); mediaService.Save(productImage); productImages.Add(productImage); productImageIds.Add(productImage.Id); } } } else { productImageIds = productImagesFolder.Children().Select(c => c.Id).ToList(); } Directory.Delete(HostingEnvironment.MapPath("~/Assets/InstallMedia"), true); } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Create media failed", ex); } #endregion #region Set up Tea Commerce Store store = null; try { //Get store or create it IReadOnlyList <Store> stores = StoreService.Instance.GetAll().ToList(); store = stores.FirstOrDefault(); if (store == null) { store = new Store("Starter Kit Store"); } store.ProductSettings.ProductVariantPropertyAlias = "variants"; store.Save(); foreach (PaymentMethod paymentMethod in PaymentMethodService.Instance.GetAll(store.Id).Where(p => p.Alias == "invoicing")) { PaymentMethodSetting setting = paymentMethod.Settings.FirstOrDefault(s => s.Key == "acceptUrl"); if (setting != null) { setting.Value = "/cart-content/confirmation/"; } paymentMethod.Save(); } } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Setting up Tea Commerce failed", ex); } #endregion #region Create Templates List <ITemplate> templates = new List <ITemplate>(); try { string[] templateFiles = Directory.GetFiles(HostingEnvironment.MapPath("~/views")); foreach (string templateFile in templateFiles) { string fileName = Path.GetFileNameWithoutExtension(templateFile); string fileContent = File.ReadAllText(templateFile); templates.Add(fileService.CreateTemplateWithIdentity(fileName, fileContent)); } } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Create templates failed", ex); } #endregion #region Set up content types IEnumerable <IDataTypeDefinition> allDataTypeDefinitions = dataTypeService.GetAllDataTypeDefinitions(); try { IDataTypeDefinition variantEditorDataTypeDefinition = allDataTypeDefinitions.FirstOrDefault(d => d.Name.ToLowerInvariant().Contains("variant editor")); variantEditorDataTypeDefinition.DatabaseType = DataTypeDatabaseType.Ntext; var preValDictionary = new Dictionary <string, object> { { "xpathOrNode", "{\"showXPath\": true,\"query\": \"$current/ancestor-or-self::frontpage/attributes\"}" }, { "variantDocumentType", "variant" }, { "extraListInformation", "sku,priceJMD" }, { "hideLabel", "1" }, }; var currVal = dataTypeService.GetPreValuesCollectionByDataTypeId(variantEditorDataTypeDefinition.Id); //we need to allow for the property editor to deserialize the prevalues PropertyEditor pe = PropertyEditorResolver.Current.PropertyEditors.SingleOrDefault(x => x.Alias == "TeaCommerce.VariantEditor"); var formattedVal = pe.PreValueEditor.ConvertEditorToDb(preValDictionary, currVal); dataTypeService.SaveDataTypeAndPreValues(variantEditorDataTypeDefinition, formattedVal); //dataTypeService.Save( variantEditorDataTypeDefinition ); variantEditorDataTypeDefinition = dataTypeService.GetDataTypeDefinitionById(variantEditorDataTypeDefinition.Id); } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Set up content types failed", ex); } #endregion #region Create Document types ContentType attributeContentType = null, attributeGroupContentType = null, attributesContentType = null, cartStepContentType = null, cartContentType = null, variantContentType = null, productContentType = null, productListContentType = null, frontpageContentType = null; try { attributeContentType = new ContentType(-1); attributeContentType.Alias = "attribute"; attributeContentType.Name = "Attribute"; attributeContentType.Icon = "icon-t-shirt"; contentTypeService.Save(attributeContentType); attributeGroupContentType = new ContentType(-1); attributeGroupContentType.Alias = "attributeGroup"; attributeGroupContentType.Name = "Attribute group"; attributeGroupContentType.Icon = "icon-t-shirt color-orange"; attributeGroupContentType.AllowedContentTypes = new List <ContentTypeSort>() { new ContentTypeSort(attributeContentType.Id, 0) }; contentTypeService.Save(attributeGroupContentType); attributesContentType = new ContentType(-1); attributesContentType.Alias = "attributes"; attributesContentType.Name = "Attributes"; attributesContentType.Icon = "icon-t-shirt"; attributesContentType.AllowedContentTypes = new List <ContentTypeSort>() { new ContentTypeSort(attributeGroupContentType.Id, 0) }; contentTypeService.Save(attributesContentType); cartStepContentType = new ContentType(-1); cartStepContentType.Alias = "cartStep"; cartStepContentType.Name = "Cart step"; cartStepContentType.Icon = "icon-shopping-basket-alt-2 color-orange"; cartStepContentType.AllowedTemplates = templates.Where(t => t.Alias.ToLowerInvariant().Contains("cartstep") && !t.Alias.ToLowerInvariant().Contains("master")); contentTypeService.Save(cartStepContentType); cartContentType = new ContentType(-1); cartContentType.Alias = "cart"; cartContentType.Name = "Cart"; cartContentType.Icon = "icon-shopping-basket-alt-2"; cartContentType.AllowedContentTypes = new List <ContentTypeSort>() { new ContentTypeSort(cartStepContentType.Id, 0) }; cartContentType.AllowedTemplates = templates.Where(t => t.Alias.ToLowerInvariant().Contains("cartstep1")); contentTypeService.Save(cartContentType); variantContentType = CreateVariantContentType(allDataTypeDefinitions, contentTypeService); productContentType = CreateProductContentType(allDataTypeDefinitions, contentTypeService, templates); productListContentType = new ContentType(-1); productListContentType.Alias = "productList"; productListContentType.Name = "Product list"; productListContentType.Icon = "icon-tags"; productListContentType.AllowedContentTypes = new List <ContentTypeSort>() { new ContentTypeSort(productContentType.Id, 0) }; productListContentType.AllowedTemplates = templates.Where(t => t.Alias.ToLowerInvariant().Contains("productlist")); contentTypeService.Save(productListContentType); frontpageContentType = CreateFrontpageContentType(allDataTypeDefinitions, contentTypeService, templates); } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Create templates failed", ex); } #endregion #region Create content try { Content frontPageContent = new Content("Home", -1, frontpageContentType); frontPageContent.Template = frontpageContentType.AllowedTemplates.First(); frontPageContent.SetValue("slider", string.Join(",", productImages.Select(p => "umb://media/" + p.Key.ToString().Replace("-", "")))); frontPageContent.SetValue("store", store.Id); contentService.SaveAndPublishWithStatus(frontPageContent, raiseEvents: false); #region Create Cart Content cartContent = new Content("Cart content", frontPageContent.Id, cartContentType); cartContent.Template = cartContentType.AllowedTemplates.First(); contentService.SaveAndPublishWithStatus(cartContent, raiseEvents: false); Content informationContent = new Content("Information", cartContent.Id, cartStepContentType); informationContent.Template = templates.First(t => t.Alias.ToLowerInvariant() == "cartstep2"); contentService.SaveAndPublishWithStatus(informationContent, raiseEvents: false); Content shippingPaymentContent = new Content("Shipping/Payment", cartContent.Id, cartStepContentType); shippingPaymentContent.Template = templates.First(t => t.Alias.ToLowerInvariant() == "cartstep3"); contentService.SaveAndPublishWithStatus(shippingPaymentContent, raiseEvents: false); Content acceptContent = new Content("Accept", cartContent.Id, cartStepContentType); acceptContent.Template = templates.First(t => t.Alias.ToLowerInvariant() == "cartstep4"); contentService.SaveAndPublishWithStatus(acceptContent, raiseEvents: false); Content paymentContent = new Content("Payment", cartContent.Id, cartStepContentType); contentService.SaveAndPublishWithStatus(paymentContent); Content confirmationContent = new Content("Confirmation", cartContent.Id, cartStepContentType); confirmationContent.Template = templates.First(t => t.Alias.ToLowerInvariant() == "cartstep6"); contentService.SaveAndPublishWithStatus(confirmationContent, raiseEvents: false); #endregion #region Create Attributes Content variantAttributesContent = new Content("Variant attributes", frontPageContent.Id, attributesContentType); contentService.SaveAndPublishWithStatus(variantAttributesContent, raiseEvents: false); Content colorContent = new Content("Color", variantAttributesContent.Id, attributeGroupContentType); contentService.SaveAndPublishWithStatus(colorContent, raiseEvents: false); Content sizeContent = new Content("Size", variantAttributesContent.Id, attributeGroupContentType); contentService.SaveAndPublishWithStatus(sizeContent, raiseEvents: false); Content blackContent = new Content("Black", colorContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(blackContent, raiseEvents: false); Content whiteContent = new Content("White", colorContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(whiteContent, raiseEvents: false); Content blueContent = new Content("Blue", colorContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(blueContent, raiseEvents: false); Content largeContent = new Content("Large", sizeContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(largeContent, raiseEvents: false); Content mediumContent = new Content("Medium", sizeContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(mediumContent, raiseEvents: false); Content smallContent = new Content("Small", sizeContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(smallContent, raiseEvents: false); #endregion #region Create Products Content expensiveYachtsContent = new Content("Expensive Yachts", frontPageContent.Id, productListContentType); expensiveYachtsContent.Template = productListContentType.AllowedTemplates.First(); contentService.SaveAndPublishWithStatus(expensiveYachtsContent, raiseEvents: false); Content veryAxpensiveYachtsContent = new Content("Very expensive Yachts", frontPageContent.Id, productListContentType); veryAxpensiveYachtsContent.Template = productListContentType.AllowedTemplates.First(); contentService.SaveAndPublishWithStatus(veryAxpensiveYachtsContent, raiseEvents: false); Content summerYachtContent = new Content("Summer Yacht", expensiveYachtsContent, productContentType); summerYachtContent.Template = productContentType.AllowedTemplates.First(); summerYachtContent.SetValue("image", "umb://media/" + productImages[0].Key.ToString().Replace("-", "")); summerYachtContent.SetValue("productName", "Summer Yacht"); summerYachtContent.SetValue("sku", "p0001"); summerYachtContent.SetValue("priceJMD", "500"); summerYachtContent.SetValue("description", "<p>This is the product description.</p>"); summerYachtContent.SetValue("variants", "{\"variants\": [],\"variantGroupsOpen\":{}}"); contentService.SaveAndPublishWithStatus(summerYachtContent, raiseEvents: false); Content yachtWithSailsContent = new Content("Yacht with sails", expensiveYachtsContent, productContentType); yachtWithSailsContent.Template = productContentType.AllowedTemplates.First(); yachtWithSailsContent.SetValue("image", "umb://media/" + productImages[1].Key.ToString().Replace("-", "")); yachtWithSailsContent.SetValue("productName", "Yacht with sails"); yachtWithSailsContent.SetValue("sku", "p0002"); yachtWithSailsContent.SetValue("priceJMD", "1000"); yachtWithSailsContent.SetValue("description", "<p>This is the product description.</p>"); yachtWithSailsContent.SetValue("variants", "{\"variants\": [],\"variantGroupsOpen\":{}}"); contentService.SaveAndPublishWithStatus(yachtWithSailsContent, raiseEvents: false); Content motorDrivenYachtContent = new Content("Motor driven Yacht", veryAxpensiveYachtsContent, productContentType); motorDrivenYachtContent.Template = productContentType.AllowedTemplates.First(); motorDrivenYachtContent.SetValue("image", "umb://media/" + productImages[2].Key.ToString().Replace("-", "")); motorDrivenYachtContent.SetValue("productName", "Motor driven Yacht"); motorDrivenYachtContent.SetValue("sku", "p0003"); motorDrivenYachtContent.SetValue("priceJMD", "1500"); motorDrivenYachtContent.SetValue("description", "<p>This is the product description.</p>"); motorDrivenYachtContent.SetValue("variants", "{\"variants\": [],\"variantGroupsOpen\":{}}"); contentService.SaveAndPublishWithStatus(motorDrivenYachtContent, raiseEvents: false); Content oneMastedYachtContent = new Content("One masted yacht", veryAxpensiveYachtsContent, productContentType); oneMastedYachtContent.Template = productContentType.AllowedTemplates.First(); oneMastedYachtContent.SetValue("image", "umb://media/" + productImages[3].Key.ToString().Replace("-", "")); oneMastedYachtContent.SetValue("productName", "One masted yacht"); oneMastedYachtContent.SetValue("sku", "p0004"); oneMastedYachtContent.SetValue("priceJMD", "2000"); oneMastedYachtContent.SetValue("description", "<p>This is the product description.</p>"); oneMastedYachtContent.SetValue("variants", "{\"variants\": [],\"variantGroupsOpen\":{}}"); contentService.SaveAndPublishWithStatus(oneMastedYachtContent, raiseEvents: false); #endregion frontPageContent.SetValue("featuredProducts", string.Join(",", new List <string> { "umb://document/" + summerYachtContent.Key.ToString().Replace("-", ""), "umb://document/" + yachtWithSailsContent.Key.ToString().Replace("-", ""), "umb://document/" + motorDrivenYachtContent.Key.ToString().Replace("-", ""), "umb://document/" + oneMastedYachtContent.Key.ToString().Replace("-", ""), })); contentService.SaveAndPublishWithStatus(frontPageContent, raiseEvents: false); } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Create content failed", ex); } #endregion return(true); }