public ForumCategoryPart GetParentCategory( ForumPart forumPart ){ ForumCategoryPart parentCategory = null; if( forumPart.As<CommonPart>().Container != null ) { parentCategory = forumPart.As<CommonPart>().Container.As<ForumCategoryPart>(); } return parentCategory; /* var parentCategoryId = _categoryToForumMappingRepository.Table.Where(rec => rec.ForumPartRecord.Id == forumPart.Id).Select(rec => rec.ForumCategoryPartRecord.Id).FirstOrDefault(); var parentCategory = _contentManager.Query<ForumCategoryPart, ForumCategoryPartRecord>().Where( cat=>cat.Id == parentCategoryId ).List().FirstOrDefault(); return parentCategory; */ }
public ThreadPart Get(ForumPart forumPart, string slug, VersionOptions versionOptions) { var threadPath = forumPart.As<IRoutableAspect>().GetChildPath(slug); return _contentManager.Query(versionOptions, ContentPartConstants.Thread).Join<RoutePartRecord>().Where(rr => rr.Path == threadPath). Join<CommonPartRecord>().Where(cr => cr.Container == forumPart.Record.ContentItemRecord).List(). SingleOrDefault().As<ThreadPart>(); }