private async Task <CustomEntityVersion> CreateDraftIfRequiredAsync( UpdateCustomEntityDraftVersionCommand command, CustomEntityVersion draft, IExecutionContext executionContext ) { if (draft != null) { return(draft); } var addDraftCommand = new AddCustomEntityDraftVersionCommand(); addDraftCommand.CustomEntityId = command.CustomEntityId; await _commandExecutor.ExecuteAsync(addDraftCommand, executionContext); return(await GetDraftVersionAsync(command)); }
public async Task <IActionResult> Post([FromBody] AddCustomEntityDraftVersionCommand command) { return(await _apiResponseHelper.RunCommandAsync(this, command)); }
public Task <JsonResult> Post([FromBody] AddCustomEntityDraftVersionCommand command) { return(_apiResponseHelper.RunCommandAsync(command)); }
public async Task ExecuteAsync(Controller controller, PageActionRoutingState state) { var pageRoutingInfo = state.PageRoutingInfo; if (pageRoutingInfo == null) { return; } // If there's no draft version and we're in edit mode for 'Pages' then // create one and re-run the query var publishStatus = state.VisualEditorState.GetPublishStatusQuery(); if (!state.InputParameters.IsEditingCustomEntity && publishStatus != PublishStatusQuery.Published && publishStatus != PublishStatusQuery.SpecificVersion && state.IsCofoundryAdminUser) { var versionRouting = pageRoutingInfo.PageRoute.Versions.GetVersionRouting(publishStatus); if (versionRouting == null) { var command = new AddPageDraftVersionCommand() { PageId = pageRoutingInfo.PageRoute.PageId }; await _commandExecutor.ExecuteAsync(command, state.CofoundryAdminExecutionContext); var pageQuery = GetPageRoutingInfoQuery(state); pageRoutingInfo = await _queryExecutor.ExecuteAsync(pageQuery); } } if (pageRoutingInfo.CustomEntityRoute != null && pageRoutingInfo.PageRoute.PageType == PageType.CustomEntityDetails) { var correctUrl = pageRoutingInfo.CustomEntityRouteRule.MakeUrl(pageRoutingInfo.PageRoute, pageRoutingInfo.CustomEntityRoute); if (!state.InputParameters.Path.Equals(correctUrl.TrimStart('/'), StringComparison.OrdinalIgnoreCase)) { Debug.WriteLine("Incorrect Custom Entity Url detected, redirecting from " + state.InputParameters.Path + " to " + correctUrl); state.Result = new RedirectResult(correctUrl, true); } else if (state.InputParameters.IsEditingCustomEntity && publishStatus != PublishStatusQuery.Published && publishStatus != PublishStatusQuery.SpecificVersion && state.IsCofoundryAdminUser) { var versionRouting = pageRoutingInfo.CustomEntityRoute.Versions.GetVersionRouting(publishStatus); if (versionRouting == null) { // if no draft version for route, add one. var addDraftVersionCommand = new AddCustomEntityDraftVersionCommand() { CustomEntityId = pageRoutingInfo.CustomEntityRoute.CustomEntityId }; await _commandExecutor.ExecuteAsync(addDraftVersionCommand, state.CofoundryAdminExecutionContext); var pageQuery = GetPageRoutingInfoQuery(state); pageRoutingInfo = await _queryExecutor.ExecuteAsync(pageQuery); } } } state.PageRoutingInfo = pageRoutingInfo; }
public async Task <int> AddDraftAsync(AddCustomEntityDraftVersionCommand command) { await ExtendableContentRepository.ExecuteCommandAsync(command); return(command.CustomEntityId); }