public virtual async Task <IActionResult> GetPostsFromMultiCategories(string categoriesNames, int page = 1, int?pageSize = null) { var materialsCategoriesDic = categoriesCache.GetAllCategoriesIncludeSub(categoriesNames); IList <CategoryCached> categoriesList = authorizationService.GetAllowedCategories(User.Roles, materialsCategoriesDic.Values, OperationKeys.MaterialAndCommentsRead); if (categoriesList.Count == 0) { return(BadRequest("No categories to show")); } var options = new MaterialsMultiCatShowOptions { CategoriesIds = categoriesList.Select(x => x.Id), Page = page, PageSize = pageSize ?? blogOptions.PostsPageSize }; var rez = await blogPresenter.GetPostsFromMultiCategoriesAsync(options); return(Json(rez)); /*async Task<IPagedList<PostViewModel>> LoadDataAsync() * { * return await blogPresenter.GetPostsFromMultiCategoriesAsync(categoriesIds, page, blogOptions.PostsPageSize); * } * * var blogCategory = categoriesCache.GetCategory(categoriesNames); * return await CacheContentAsync(blogCategory, categoriesIds, LoadDataAsync);*/ }
public virtual async Task <IActionResult> GetNewTopics(string categoryName, int page = 1) { var categoryParent = categoriesCache.GetCategory(categoryName); if (categoryParent == null) { return(BadRequest()); } var allCategories = categoryParent.AllSubCategories.Where(x => x.IsMaterialsContainer); var categories = authorizationService.GetAllowedCategories(User.Roles, allCategories, OperationKeys.MaterialAndCommentsRead); var categoriesIds = categories.Select(x => x.Id); var options = new MaterialsMultiCatShowOptions { CategoriesIds = categoriesIds, Page = page, PageSize = forumOptions.NewTopicsPageSize }; async Task <IPagedList <TopicInfoView> > LoadDataAsync() { return(await forumPresenter.GetNewTopicsAsync(options, forumOptions.NewTopicsMaxPages)); } return(await CacheContentAsync(categoryParent, categoriesIds, LoadDataAsync, page)); }
public virtual async Task <IActionResult> GetPostsFromMultiCategories(string sectionName, int page = 1) { var section = sectionsCache.GetSectionserverCached(sectionName, User.Roles); if (section == null) { return(BadRequest($"No component {sectionName} found in cache")); } PostsServerSectionData sectionData = (PostsServerSectionData)section.Data; var materialsCategoriesDic = categoriesCache.GetAllCategoriesWithChildren(sectionData.Categories); var materialsCategoriesExcludeDic = categoriesCache.GetAllCategoriesWithChildren(sectionData.CategoriesExclude); foreach (var(key, _) in materialsCategoriesExcludeDic) { materialsCategoriesDic.Remove(key); } var categoriesList = authorizationService.GetAllowedCategories(User.Roles, materialsCategoriesDic.Values, OperationKeys.MaterialAndCommentsRead); if (categoriesList.Count == 0) { return(BadRequest("No categories to show")); } var categoriesIds = categoriesList.Select(x => x.Id); var options = new MaterialsMultiCatShowOptions { CategoriesIds = categoriesList.Select(x => x.Id), Page = page, PageSize = sectionData.PageSize, PreviewSize = sectionData.PreviewSize }; return(await CacheContentAsync(section, categoriesIds, LoadDataAsync, page)); async Task <IPagedList <PostView> > LoadDataAsync() => await blogPresenter.GetPostsFromMultiCategoriesAsync(options); }
public virtual async Task <IActionResult> GetPostsFromMultiCategories(string componentName, int page = 1) { var component = componentsCache.GetComponentServerCached(componentName, User.Roles); if (component == null) { return(BadRequest($"No component {componentName} found in cache")); } PostsComponentData componentData = component.Data as PostsComponentData; var materialsCategoriesDic = categoriesCache.GetAllCategoriesWithChildren(componentData.CategoriesNames); IList <CategoryCached> categoriesList = authorizationService.GetAllowedCategories(User.Roles, materialsCategoriesDic.Values, OperationKeys.MaterialAndCommentsRead); if (categoriesList.Count == 0) { return(BadRequest("No categories to show")); } var categoriesIds = categoriesList.Select(x => x.Id); var options = new MaterialsMultiCatShowOptions { CategoriesIds = categoriesList.Select(x => x.Id), Page = page, PageSize = componentData.PageSize, PreviewSize = componentData.PreviewSize }; async Task <IPagedList <PostView> > LoadDataAsync() { return(await blogPresenter.GetPostsFromMultiCategoriesAsync(options)); } return(await CacheContentAsync(component, categoriesIds, LoadDataAsync, page)); }
public virtual async Task <IActionResult> GetArticlesFromMultiCategories(string categoriesNames, int page = 1) { var materialsCategoriesDic = categoriesCache.GetAllCategoriesIncludeSub(categoriesNames); IList <CategoryCached> categoriesList = authorizationService.GetAllowedCategories(User.Roles, materialsCategoriesDic.Values, OperationKeys.MaterialAndCommentsRead); if (categoriesList.Count == 0) { return(BadRequest("No categories to show")); } var options = new MaterialsMultiCatShowOptions() { CategoriesIds = categoriesList.Select(x => x.Id), Page = page, PageSize = articlesOptions.CategoryPageSize }; IPagedList <ArticleInfoView> articles = await articlesPresenter.GetArticlesFromMultiCategoriesAsync(options); return(Json(articles)); }