예제 #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;
            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()
        {
            // ModelBinder is not supported in view components so we have to bind
            // this manually. We have an issue open to try and improve the experience here
            // https://github.com/cofoundry-cms/cofoundry/issues/125
            var webQuery = new SearchBlogPostsQuery();

            webQuery.PageNumber = IntParser.ParseOrDefault(Request.Query[nameof(webQuery.PageNumber)]);
            webQuery.PageSize   = IntParser.ParseOrDefault(Request.Query[nameof(webQuery.PageSize)]);
            webQuery.CategoryId = IntParser.ParseOrDefault(Request.Query[nameof(webQuery.CategoryId)]);

            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
            // See issue https://github.com/cofoundry-cms/cofoundry/issues/12

            var entities = await _customEntityRepository.SearchCustomEntityRenderSummariesAsync(query);

            var viewModel = await MapBlogPostsAsync(entities);

            return(View(viewModel));
        }
예제 #3
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var webQuery = ModelBind();

            // We can use the current visual editor state (e.g. edit mode, live mode) to
            // determine whether to show unpublished blog posts in the list.
            var visualEditorState = await _visualEditorStateService.GetCurrentAsync();

            var ambientEntityPublishStatusQuery = visualEditorState.GetAmbientEntityPublishStatusQuery();

            var query = new SearchCustomEntityRenderSummariesQuery()
            {
                CustomEntityDefinitionCode = BlogPostCustomEntityDefinition.DefinitionCode,
                PageNumber    = webQuery.PageNumber,
                PageSize      = 30,
                PublishStatus = ambientEntityPublishStatusQuery
            };

            // 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
            // See issue https://github.com/cofoundry-cms/cofoundry/issues/12

            var entities = await _customEntityRepository.SearchCustomEntityRenderSummariesAsync(query);

            var viewModel = await MapBlogPostsAsync(entities, ambientEntityPublishStatusQuery);

            return(View(viewModel));
        }
예제 #4
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var query = new SearchCustomEntityRenderSummariesQuery();

            query.CustomEntityDefinitionCode = BlogPostCustomEntityDefinition.DefinitionCode;
            query.PageSize = 3;

            var entities = await _customEntityRepository.SearchCustomEntityRenderSummariesAsync(query);

            var viewModel = await MapBlogPostsAsync(entities);

            return(View(viewModel));
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var query = new SearchCustomEntityRenderSummariesQuery();

            query.CustomEntityDefinitionCode = CategoryCustomEntityDefinition.DefinitionCode;
            query.PageSize = 20;
            query.SortBy   = CustomEntityQuerySortType.Title;

            var entities = await _customEntityRepository.SearchCustomEntityRenderSummariesAsync(query);

            var viewModel = MapCategories(entities);

            return(View(viewModel));
        }
예제 #6
0
        public async Task <PagedQueryResult <FlowerSummary> > ExecuteAsync(SearchFlowerSummariesQuery query, IExecutionContext executionContext)
        {
            var customEntityQuery = new SearchCustomEntityRenderSummariesQuery();

            customEntityQuery.CustomEntityDefinitionCode = FlowerCustomEntityDefinition.DefinitionCode;
            customEntityQuery.PageSize      = query.PageSize;
            customEntityQuery.PageNumber    = query.PageNumber;
            customEntityQuery.PublishStatus = PublishStatusQuery.Published;
            customEntityQuery.SortBy        = CustomEntityQuerySortType.PublishDate;
            var FlowerCustomEntities = await _customEntityRepository.SearchCustomEntityRenderSummariesAsync(customEntityQuery);

            var allMainImages = await GetMainImages(FlowerCustomEntities);

            return(await MapFlowers(FlowerCustomEntities, allMainImages, query.CategoryId));
        }
예제 #7
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var visualEditorState = await _visualEditorStateService.GetCurrentAsync();

            var query = new SearchCustomEntityRenderSummariesQuery();

            query.CustomEntityDefinitionCode = BlogPostCustomEntityDefinition.DefinitionCode;
            query.PublishStatus = visualEditorState.GetAmbientEntityPublishStatusQuery();
            query.PageSize      = 3;

            var entities = await _customEntityRepository.SearchCustomEntityRenderSummariesAsync(query);

            var viewModel = await MapBlogPostsAsync(entities);

            return(View(viewModel));
        }
예제 #8
0
        public async Task <PagedQueryResult <PlayerSummary> > ExecuteAsync(SearchPlayerSummariesQuery query, IExecutionContext executionContext)
        {
            var customEntityQuery = new SearchCustomEntityRenderSummariesQuery();

            customEntityQuery.CustomEntityDefinitionCode = PlayerCustomEntityDefinition.DefinitionCode;
            customEntityQuery.PageSize      = query.PageSize = query.PageSize;
            customEntityQuery.PageNumber    = query.PageNumber;
            customEntityQuery.PublishStatus = PublishStatusQuery.Published;
            customEntityQuery.SortBy        = CustomEntityQuerySortType.PublishDate;

            var catCustomEntities = await _customEntityRepository.SearchCustomEntityRenderSummariesAsync(customEntityQuery);

            var allMainImages = await GetMainImages(catCustomEntities);

            var allLikeCounts = await GetLikeCounts(catCustomEntities);

            return(MapPlayers(catCustomEntities, allMainImages, allLikeCounts));
        }
예제 #9
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            // We can use the current visual editor state (e.g. edit mode, live mode) to
            // determine whether to show unpublished categories in the list.
            var visualEditorState = await _visualEditorStateService.GetCurrentAsync();

            var query = new SearchCustomEntityRenderSummariesQuery()
            {
                CustomEntityDefinitionCode = CategoryCustomEntityDefinition.DefinitionCode,
                PageSize      = 20,
                PublishStatus = visualEditorState.GetAmbientEntityPublishStatusQuery()
            };

            var entities = await _customEntityRepository.SearchCustomEntityRenderSummariesAsync(query);

            var viewModel = MapCategories(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));
        }