public virtual async Task <IActionResult> GetMaterials(GetMaterialsRequest materialsRequest)
        {
            SectionServerCached section = sectionsCache.GetSectionServerCached(materialsRequest.SectionName, User.Roles);

            if (section == null)
            {
                return(BadRequest($"No component {materialsRequest.SectionName} found in cache"));
            }

            MaterialsServerSection sectionData = section.GetData <MaterialsServerSection>();

            if (!("," + sectionData.CategoriesNames + ",").Contains("," + materialsRequest.CategoryName + ","))
            {
                return(BadRequest(
                           $"Can not show {materialsRequest.CategoryName} in {materialsRequest.SectionName} section"));
            }

            CategoryCached category = categoriesCache.GetCategory(materialsRequest.CategoryName);

            if (category == null)
            {
                return(BadRequest($"Can not find {materialsRequest.CategoryName} category"));
            }


            MaterialsShowOptions options = new MaterialsShowOptions
            {
                ShowDeleted = materialsRequest.ShowDeleted,
                CategoryId  = category.Id,
                Page        = materialsRequest.Page,
                Sort        = MaterialsSortOptionsService.MaterialsSortOptions[materialsRequest.Sort]
            };

            using var scope = serviceProvider.CreateScope();
            IMaterialsQueryPresenter materialsQueryPresenter =
                (IMaterialsQueryPresenter)scope.ServiceProvider.GetRequiredService(MaterialsPresenterTypes.GetBySection(section));

            return(await CacheContentAsync(category, category.Id,
                                           () => materialsQueryPresenter.GetMaterialsByCategoryAsync(options), new RequestOptions()
            {
                Sort = materialsRequest.Sort,
                PageNumber = materialsRequest.Page
            }));
        }
        public virtual async Task <IActionResult> GetMaterialsFromMultiCategories(GetMaterialsRequest materialsRequest)
        {
            SectionServerCached section = sectionsCache.GetSectionServerCached(materialsRequest.SectionName, User.Roles);

            if (section == null)
            {
                return(BadRequest($"No component {materialsRequest.SectionName} found in cache"));
            }

            MaterialsServerSection sectionData = section.GetData <MaterialsServerSection>();

            var сategories = categoriesCache.GetAllCategoriesWithChildren(sectionData.CategoriesNames);

            IList <CategoryCached> categories = authorizationService.GetAllowedCategories(User.Roles,
                                                                                          сategories.Values, operationKeysContainer.MaterialAndCommentsRead);

            if (categories.Count == 0)
            {
                return(BadRequest("No categories to show"));
            }

            IEnumerable <int> categoriesIds = categories.Select(x => x.Id).ToArray();

            MaterialsSortOptionsService.MaterialsSortOptions.TryGetValue(materialsRequest.Sort,
                                                                         out Func <IQueryable <Material>, IOrderedQueryable <Material> > sort);

            var options = new MaterialsShowOptions
            {
                CategoriesIds = categoriesIds,
                Page          = materialsRequest.Page,
                PageSize      = sectionData.PageSize,
                Sort          = sort
            };

            using var scope = serviceProvider.CreateScope();
            IMaterialsQueryPresenter materialsQueryPresenter =
                (IMaterialsQueryPresenter)scope.ServiceProvider.GetRequiredService(MaterialsPresenterTypes.GetBySection(section));

            return(await CacheContentAsync(section, categoriesIds,
                                           () => materialsQueryPresenter.GetMaterialsFromMultiCategoryAsync(options), materialsRequest.Page));
        }