/// <summary> /// Extends the language models with a link to each language. /// The links are used in Assets/Scripts/components/LanguageSelector.vue /// </summary> private void ExtendLanguageModels(ContentApiModel contentModel, IContent content) { var listPublished = _versionRepository.ListPublished(content.ContentLink); var listLanguagesWithPublishedContents = listPublished.Select(x => x.LanguageBranch); // Filter the existingLanguages list to make it contain only languages which has a published version contentModel.ExistingLanguages = contentModel.ExistingLanguages.Where(x => listLanguagesWithPublishedContents.Contains(x.Name)).Select(x => new ExtendedLanguageModel(x) { Link = ResolveUrl(content.ContentLink, x.Name) }).ToList <LanguageModel>(); }
public void DeleteSingleVariantProduct(VariationContent variant) { _log.Information("DeleteSingleVariantProduct: " + variant.Code); if (!_configuration.ProductsImportUrl.IsValidProductsImportUrl()) { _log.Information("Skipped single variant product delete because url is not valid: " + _configuration.ProductsImportUrl); return; } // Bail if not published var isPublished = _contentVersionRepository.ListPublished(variant.ContentLink).Count() > 0; if (!isPublished) { _log.Information("Skipped single variant product delete because it's not yet published"); return; } var ids = new List <string>(); ids.Add(variant.Code.SanitizeKey()); APIFacade.Delete(ids, _configuration.ProductsImportUrl); }
private FoldersAndTags BuildTagsAndFolders(IEnumerable <NodeContent> nodes) { var result = new FoldersAndTags(); foreach (var node in nodes) { // continue if not published var isPublished = _contentVersionRepository.ListPublished(node.ContentLink).Count() > 0; if (!isPublished) { _log.Information("Skipped product because it's not yet published"); continue; } var tag = new Tag(); tag.TagValue = node.Code.SanitizeKey(); tag.Name = _l10nStringFactory.GetLocalizedString(node, nameof(node.DisplayName)); _log.Information("Category code: " + node.Code); result.Tags[tag.TagValue] = tag; var folder = new Folder(tag.TagValue); result.Folders.Add(folder); var childrenNodes = _contentLoader.GetChildren <NodeContent>(node.ContentLink); if (childrenNodes.Count() > 0) { var childrenFoldersAndTags = BuildTagsAndFolders(childrenNodes); folder.Children = childrenFoldersAndTags.Folders; foreach (var pair in childrenFoldersAndTags.Tags) { result.Tags[pair.Key] = pair.Value; } } } return(result); }