public IEnumerable<PageData> GetContent(ContentReference contentRef, string scope = null) { var refs = scope == null ? Store.Items<CategoryAssignment>().Where(ca => ca.CategoryPage == contentRef.ToReferenceWithoutVersion()).ToList() : Store.Items<CategoryAssignment>().Where(ca => ca.CategoryPage == contentRef.ToReferenceWithoutVersion() && ca.Scope == scope).ToList(); var repo = ServiceLocator.Current.GetInstance<IContentRepository>(); return refs.Select(ca => repo.Get<PageData>(ca.ContentPage)).Where(x => !x.IsDeleted); }
public void DeleteAssignmentsByCategory(ContentReference categoryRef) { if (Store.Items<CategoryAssignment>().Where(ca => ca.ContentPage == categoryRef.ToReferenceWithoutVersion()).Count() > 0) { foreach (var item in Store.Items<CategoryAssignment>().Where(ca => ca.CategoryPage == categoryRef.ToReferenceWithoutVersion())) { Store.Delete(item); } } }
public void AddAssignment(ContentReference contentRef, ContentReference categoryRef, string scope) { contentRef = contentRef.ToReferenceWithoutVersion(); categoryRef = categoryRef.ToReferenceWithoutVersion(); var matchingAssignments = Store.Items<CategoryAssignment>().Where(ca => ca.ContentPage == contentRef && ca.CategoryPage == categoryRef && ca.Scope == scope); if(matchingAssignments.Count() > 0) { return; } var categoryAssignment = new CategoryAssignment() { ContentPage = contentRef, CategoryPage = categoryRef, Scope = scope }; Store.Save(categoryAssignment); }
protected virtual IEnumerable<HrefLangData> GetHrefLangDataFromCache(ContentReference contentLink) { var cacheKey = string.Format("HrefLangData-{0}", contentLink.ToReferenceWithoutVersion()); var cachedObject = CacheManager.Get(cacheKey) as IEnumerable<HrefLangData>; if (cachedObject == null) { cachedObject = GetHrefLangData(contentLink); CacheManager.Insert(cacheKey, cachedObject, new CacheEvictionPolicy(null, new [] { "SitemapGenerationKey" }, TimeSpan.FromMinutes(10), CacheTimeoutType.Absolute)); } return cachedObject; }