Exemple #1
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            // TODO: no model binder access....
            // https://github.com/aspnet/Mvc/blob/master/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Internal/ModelBindingHelper.cs
            //HttpContext.Request.
            var webQuery = new SearchBlogPostsQuery();
            //---------

            var query = new SearchCustomEntityRenderSummariesQuery();

            query.CustomEntityDefinitionCode = BlogPostCustomEntityDefinition.DefinitionCode;
            query.PageNumber = webQuery.PageNumber;
            query.PageSize   = 30;

            // Publish status defaults to live, but we can use the current visual editor
            // state to allow us to show draft blog posts when previewing a draft page.
            var state = await _visualEditorStateService.GetCurrentAsync();

            query.PublishStatus = state.GetAmbientEntityPublishStatusQuery();

            // TODO: Filtering by Category (webQuery.CategoryId)
            // Searching/filtering custom entities is not implemented yet, but it
            // is possible to build your own search index using the message handling
            // framework or writing a custom query against the UnstructuredDataDependency table

            var entities = await _contentRepository
                           .CustomEntities()
                           .Search()
                           .AsRenderSummaries(query)
                           .ExecuteAsync();

            var viewModel = await MapBlogPostsAsync(entities);

            return(View(viewModel));
        }
Exemple #2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            // TODO: no model binder access....
            // https://github.com/aspnet/Mvc/blob/master/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Internal/ModelBindingHelper.cs
            //HttpContext.Request.
            var webQuery = new SearchBlogPostsQuery();
            //---------

            var query = new SearchCustomEntityRenderSummariesQuery();

            query.CustomEntityDefinitionCode = BlogPostCustomEntityDefinition.DefinitionCode;
            query.PageNumber    = webQuery.PageNumber;
            query.PageSize      = 30;
            query.PublishStatus = PublishStatusQuery.Published;

            // TODO: Filtering by Category (webQuery.CategoryId)
            // Searching/filtering custom entities is not implemented yet, but it
            // is possible to build your own search index using the message handling
            // framework or writing a custom query against the UnstructuredDataDependency table

            var entities = await _customEntityRepository.SearchCustomEntityRenderSummariesAsync(query);

            var viewModel = await MapBlogPostsAsync(entities);

            return(View(viewModel));
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            // TODO: no model binder access....
            // https://github.com/aspnet/Mvc/blob/master/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Internal/ModelBindingHelper.cs
            //HttpContext.Request.
            var webQuery = new SearchBlogPostsQuery();
            //---------

            var query = new SearchCustomEntitiesQuery();

            query.CustomEntityDefinitionCode = BlogPostCustomEntityDefinition.DefinitionCode;
            query.PageNumber = webQuery.PageNumber;
            query.PageSize   = 30;

            var specifications = new List <ICustomEntitySearchSpecification <BlogPostDataModel> >();

            //decide which filters to add, they all get linked by AND
            //for OR specifications you will need to define them in the satisfied by predicate
            specifications.Add(new BlogPostCategorySpecification(1));
            //basically in this setup every operation thats understood by ef core / remotion can be used to query
            //specifications.Add(new BlogPostShortDescriptionContainsSpecification("test"));
            query.Specifications = specifications;


            // Publish status defaults to live, but we can use the current visual editor
            // state to allow us to show draft blog posts when previewing a draft page.
            var state = await _visualEditorStateService.GetCurrentAsync();

            query.PublishStatus = state.GetAmbientEntityPublishStatusQuery();

            // TODO: Filtering by Category (webQuery.CategoryId)
            // Searching/filtering custom entities is not implemented yet, but it
            // is possible to build your own search index using the message handling
            // framework or writing a custom query against the UnstructuredDataDependency table

            var entities = await _customEntityRepository.SearchCustomEntityRenderSummariesAsync(query);

            var viewModel = await MapBlogPostsAsync(entities);

            return(View(viewModel));
        }