private void CreateRepositories(IContentService contentService, IContent siteContainer) { // create repositories var repository = contentService.CreateAndSave("Data Repositories", siteContainer.Id, DataRepositories.ModelTypeAlias); contentService.CreateAndSave("Authors", repository.Id, Authors.ModelTypeAlias); contentService.CreateAndSave("Categories", repository.Id, Categories.ModelTypeAlias); contentService.CreateAndSave("Tags", repository.Id, Tags.ModelTypeAlias); }
private void CreatePages(IContentService contentService, IContent siteRoot) { // home var home = contentService.CreateAndSave("Home", siteRoot.Id, HomePage.ModelTypeAlias); siteRoot.SetValue("umbracoInternalRedirectId", home.GetUdi()); contentService.Save(siteRoot, raiseEvents: false); // basic pages contentService.CreateAndSave("Page Not Found", siteRoot.Id, Error404.ModelTypeAlias); contentService.CreateAndSave("Terms And Conditions", siteRoot.Id, ContentPage.ModelTypeAlias); }
/// <summary> /// When a new root Articulate node is created, then create the required 2 sub nodes /// </summary> private void ContentService_Saved(IContentService contentService, SaveEventArgs <IContent> e) { foreach (var c in e.SavedEntities) { if (!c.WasPropertyDirty("Id") || !c.ContentType.Alias.InvariantEquals(ArticulateContentTypeAlias)) { continue; } //it's a root blog node, set up the required sub nodes (archive , authors) if they don't exist var defaultLang = _languageService.GetDefaultLanguageIsoCode(); var children = contentService.GetPagedChildren(c.Id, 0, 10, out var total).ToList(); if (total == 0 || children.All(x => x.ContentType.Alias != "ArticulateArchive")) { var archiveContentType = _contentTypeService.Get("ArticulateArchive"); if (archiveContentType != null) { if (archiveContentType.VariesByCulture()) { var articles = contentService.Create("", c, "ArticulateArchive"); articles.SetCultureName("Archive", defaultLang); contentService.Save(articles); } else { var articles = contentService.CreateAndSave("Archive", c, "ArticulateArchive"); } } } if (total == 0 || children.All(x => x.ContentType.Alias != "ArticulateAuthors")) { var authorContentType = _contentTypeService.Get("ArticulateAuthors"); if (authorContentType != null) { if (authorContentType.VariesByCulture()) { var authors = contentService.Create("", c, "ArticulateAuthors"); authors.SetCultureName("Authors", defaultLang); contentService.Save(authors); } else { var authors = contentService.CreateAndSave("Authors", c, "ArticulateAuthors"); } } } } }
public override PipelineResult <InstallPipelineContext> Execute(PipelineArgs <InstallPipelineContext> args) { using (var scope = _scopeProvider.CreateScope()) { var vendrCheckoutPageContenType = _contentTypeService.Get(VendrCheckoutConstants.ContentTypes.Aliases.CheckoutPage); var vendrCheckoutStepPageContenType = _contentTypeService.Get(VendrCheckoutConstants.ContentTypes.Aliases.CheckoutStepPage); // Check to see if the checkout node already exists var filter = scope.SqlContext.Query <IContent>().Where(x => x.ContentTypeId == vendrCheckoutPageContenType.Id); var childNodes = _contentService.GetPagedChildren(args.Model.SiteRootNodeId, 1, 1, out long totalRecords, filter); if (totalRecords == 0) { // Create the checkout page var checkoutNode = _contentService.CreateAndSave("Checkout", args.Model.SiteRootNodeId, VendrCheckoutConstants.ContentTypes.Aliases.CheckoutPage); // Create the checkout steps pages CreateCheckoutStepPage(checkoutNode, "Customer Information", "Information", "Information"); CreateCheckoutStepPage(checkoutNode, "Shipping Method", "Shipping Method", "ShippingMethod"); CreateCheckoutStepPage(checkoutNode, "Payment Method", "Payment Method", "PaymentMethod"); CreateCheckoutStepPage(checkoutNode, "Review Order", "Review", "Review"); CreateCheckoutStepPage(checkoutNode, "Process Payment", "Payment", "Payment"); CreateCheckoutStepPage(checkoutNode, "Order Confirmation", "Confirmation", "Confirmation"); } scope.Complete(); } // Continue the pipeline return(Ok()); }
/// <summary> /// 取得特定子節點 /// </summary> /// <param name="pid">父節點代碼</param> /// <param name="childContentTypeAlias">子節點代名</param> /// <param name="childNodeName">子節點名稱</param> /// <returns></returns> public IContent GetChildNode(int pid, string childContentTypeAlias, string childNodeName = null) { IContent childNode = (childNodeName == null) ? this.GetChildNodes(pid, childContentTypeAlias).FirstOrDefault() : this.GetChildNodes(pid, childContentTypeAlias).FirstOrDefault(x => x.Name == childNodeName); if (childNode == null) { childNode = _service.CreateAndSave(childNodeName ?? childContentTypeAlias, pid, childContentTypeAlias); } if (!childNode.Published) { _service.SaveAndPublish(childNode); } return(childNode); }
private void CreatePages(IContentService contentService, IContent siteRoot) { // home var home = contentService.CreateAndSave("Home", siteRoot.Id, Home.ModelTypeAlias); home.SetValue("title", home.Name); siteRoot.SetValue("umbracoInternalRedirectId", home.GetUdi()); contentService.Save(siteRoot, raiseEvents: false); // basic pages var error404 = contentService.CreateAndSave("Page Not Found", siteRoot.Id, Error404.ModelTypeAlias); error404.SetValue("title", error404.Name); contentService.Save(error404, raiseEvents: false); var terms = contentService.CreateAndSave("Terms And Conditions", siteRoot.Id, BasicContent.ModelTypeAlias); terms.SetValue("title", terms.Name); contentService.Save(terms, raiseEvents: false); }
/// <summary> /// When a new root Articulate node is created, then create the required 2 sub nodes /// </summary> private void ContentService_Saved(IContentService sender, SaveEventArgs <IContent> e) { foreach (var c in e.SavedEntities) { if (!c.WasPropertyDirty("Id") || !c.ContentType.Alias.InvariantEquals(ArticulateContentTypeAlias)) { continue; } //it's a root blog node, set up the required sub nodes (archive , authors) if they don't exist var children = sender.GetPagedChildren(c.Id, 0, 10, out var total).ToList(); if (total == 0 || children.All(x => x.ContentType.Alias != "ArticulateArchive")) { var articles = sender.CreateAndSave("Archive", c, "ArticulateArchive"); } if (total == 0 || children.All(x => x.ContentType.Alias != "ArticulateArchive")) { var authors = sender.CreateAndSave("Authors", c, "ArticulateAuthors"); } } }
private IContent CreateSiteRoot(IContentService contentService, IContent siteContainer, IDomainService domainService, ILocalizationService localizationService, string domain) { var siteRoot = contentService.CreateAndSave("Website", siteContainer.Id, SiteRoot.ModelTypeAlias); // add hostname var language = localizationService.GetAllLanguages().First(); if (domainService.GetByName(domain) != null) { domain = $"{domain}/{siteContainer.Name}"; } domainService.Save(new UmbracoDomain(domain) { LanguageId = language.Id, RootContentId = siteRoot.Id, DomainName = domain }); return(siteRoot); }
/// <inheritdoc /> public IContent CreateContent(string name, Guid parentId, string documentTypeAlias, CancellationToken cancellationToken) { var parentContent = _contentService.GetById(parentId); return(_contentService.CreateAndSave(name, parentContent, documentTypeAlias)); }
public IContent CreateAndSave(string name, int parentId, string contentTypeAlias, int userId = -1) { return(inner.CreateAndSave(name, parentId, contentTypeAlias, userId)); }