public async Task ExecuteAsync(Controller controller, PageActionRoutingState state) { // The ambient auth schema might not be the cofoundry admin scheme // So we will attempt to find the cofoundry user to execute the contoller with // falling back to the user authenticated with the ambient scheme state.AmbientUserContext = await _userContextService.GetCurrentContextAsync(); IUserContext cofoundryUserContext = null; if (state.AmbientUserContext.IsCofoundryUser()) { cofoundryUserContext = state.AmbientUserContext; } else { cofoundryUserContext = await _userContextService.GetCurrentContextByUserAreaAsync(CofoundryAdminUserArea.AreaCode); } if (cofoundryUserContext.IsCofoundryUser()) { state.IsCofoundryAdminUser = true; state.CofoundryAdminUserContext = cofoundryUserContext; state.CofoundryAdminExecutionContext = _executionContextFactory.Create(state.CofoundryAdminUserContext); } state.VisualEditorState = await _visualEditorStateService.GetCurrentAsync(); }
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)); }
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 blog posts in the list. var visualEditorState = await _visualEditorStateService.GetCurrentAsync(); var ambientEntityPublishStatusQuery = visualEditorState.GetAmbientEntityPublishStatusQuery(); var query = new SearchCustomEntityRenderSummariesQuery() { CustomEntityDefinitionCode = BlogPostCustomEntityDefinition.DefinitionCode, PageNumber = 1, PageSize = 5, PublishStatus = ambientEntityPublishStatusQuery }; var entities = await _contentRepository .CustomEntities() .Search() .AsRenderSummaries(query) .ExecuteAsync(); var posts = await MapBlogPostsAsync(entities, ambientEntityPublishStatusQuery); var viewModel = new BlogPostListViewModel { BlogPosts = posts }; return View(viewModel); }
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 _contentRepository .CustomEntities() .Search() .AsRenderSummaries(query) .ExecuteAsync(); var viewModel = await MapBlogPostsAsync(entities, ambientEntityPublishStatusQuery); return(View(viewModel)); }
private async Task <string> RenderRegion(PageRegionRenderDetails pageRegion) { var regionAttributes = new Dictionary <string, string>(); var visualEditorState = await _visualEditorStateService.GetCurrentAsync(); var blocksHtml = await RenderBlocksToHtml(pageRegion, regionAttributes, visualEditorState); // If we're not in edit mode just return the blocks. if (visualEditorState.VisualEditorMode != VisualEditorMode.Edit) { if (_wrappingTagName != null) { return(TemplateRegionTagBuilderHelper.WrapInTag( blocksHtml, _wrappingTagName, _allowMultipleBlocks, _additonalHtmlAttributes )); } return(blocksHtml); } regionAttributes.Add("data-cms-page-template-region-id", pageRegion.PageTemplateRegionId.ToString()); regionAttributes.Add("data-cms-page-region-name", pageRegion.Name); regionAttributes.Add("data-cms-page-region", string.Empty); regionAttributes.Add("class", "cofoundry__sv-region"); if (_permittedBlocks.Any()) { regionAttributes.Add("data-cms-page-region-permitted-block-types", string.Join(",", _permittedBlocks)); } if (_allowMultipleBlocks) { regionAttributes.Add("data-cms-multi-block", "true"); if (_emptyContentMinHeight.HasValue) { regionAttributes.Add("style", "min-height:" + _emptyContentMinHeight + "px"); } } return(TemplateRegionTagBuilderHelper.WrapInTag( blocksHtml, _wrappingTagName, _allowMultipleBlocks, _additonalHtmlAttributes, regionAttributes )); }
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)); }
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)); }
public async Task ExecuteAsync(Controller controller, PageActionRoutingState state) { state.VisualEditorState = await _visualEditorStateService.GetCurrentAsync(); }