/// <inheritdoc/> public async Task <ContentState> SetContentWorkflowStateAsync( string slug, string contentId, string workflowId, string stateName, CmsIdentity stateChangedBy) { if (slug is null) { throw new ArgumentNullException(nameof(slug)); } if (string.IsNullOrEmpty(contentId)) { throw new ArgumentException("message", nameof(contentId)); } if (string.IsNullOrEmpty(workflowId)) { throw new ArgumentException("message", nameof(workflowId)); } if (string.IsNullOrEmpty(stateName)) { throw new ArgumentException("message", nameof(stateName)); } ItemResponse <ContentState> response = await this.container.CreateItemAsync( new ContentState { Slug = slug, ContentId = contentId, StateName = stateName, WorkflowId = workflowId, ChangedBy = stateChangedBy }, new PartitionKey(PartitionKeyHelper.GetPartitionKeyFromSlug(slug))).ConfigureAwait(false); return(response.Resource); }
/// <summary> /// Reverts the content to a draft state in the <see cref="WellKnownWorkflowId.ContentPublication"/> workflow. /// </summary> /// <param name="contentStore">The content store for which this is an extension.</param> /// <param name="slug">The slug for which to publish the content.</param> /// <param name="stateChangedBy">The identity that made the change.</param> /// <returns>A <see cref="Task"/> which completes when the content is published.</returns> public static async Task MakeDraftContentAsync(this IContentStore contentStore, string slug, CmsIdentity stateChangedBy) { if (contentStore is null) { throw new ArgumentNullException(nameof(contentStore)); } if (slug is null) { throw new ArgumentNullException(nameof(slug)); } ContentState contentState = await contentStore.GetContentStateForWorkflowAsync(slug, WellKnownWorkflowId.ContentPublication).ConfigureAwait(false); await contentStore.SetContentWorkflowStateAsync(slug, contentState.ContentId, WellKnownWorkflowId.ContentPublication, ContentPublicationContentState.Draft, stateChangedBy).ConfigureAwait(false); }
/// <summary> /// Copies the given content in the <see cref="WellKnownWorkflowId.ContentPublication"/> workflow. /// </summary> /// <param name="contentStore">The content store for which this is an extension.</param> /// <param name="targetSlug">The slug to which to move the content.</param> /// <param name="originalSlug">The slug from which the content is to be moved.</param> /// <param name="stateChangedBy">The identity that made the change.</param> /// <param name="targetState">The target state for the copy; the default is <see cref="ContentPublicationContentState.Draft"/>.</param> /// <returns>A <see cref="Task"/> which completes when the content is published.</returns> public static async Task <Content> CopyContentForPublicationAsync(this IContentStore contentStore, string targetSlug, string originalSlug, CmsIdentity stateChangedBy, string targetState = ContentPublicationContentState.Draft) { if (contentStore is null) { throw new ArgumentNullException(nameof(contentStore)); } if (targetSlug is null) { throw new ArgumentNullException(nameof(targetSlug)); } if (originalSlug is null) { throw new ArgumentNullException(nameof(originalSlug)); } ContentState state = await contentStore.GetContentStateForWorkflowAsync(originalSlug, WellKnownWorkflowId.ContentPublication).ConfigureAwait(false); Content copiedContent = await contentStore.CopyContentAsync(targetSlug, state.ContentId, originalSlug).ConfigureAwait(false); await contentStore.SetContentWorkflowStateAsync(targetSlug, copiedContent.Id, WellKnownWorkflowId.ContentPublication, targetState, stateChangedBy).ConfigureAwait(false); return(copiedContent); }
/// <summary> /// Publishes the given content in the <see cref="WellKnownWorkflowId.ContentPublication"/> workflow. /// </summary> /// <param name="contentStore">The content store for which this is an extension.</param> /// <param name="slug">The slug for which to publish the content.</param> /// <param name="contentId">The ID of the content to be published.</param> /// <param name="stateChangedBy">The identity that made the change.</param> /// <returns>A <see cref="Task"/> which completes when the content is published.</returns> public static Task PublishContentAsync(this IContentStore contentStore, string slug, string contentId, CmsIdentity stateChangedBy) { if (contentStore is null) { throw new ArgumentNullException(nameof(contentStore)); } if (slug is null) { throw new ArgumentNullException(nameof(slug)); } if (string.IsNullOrEmpty(contentId)) { throw new ArgumentException("message", nameof(contentId)); } return(contentStore.SetContentWorkflowStateAsync(slug, contentId, WellKnownWorkflowId.ContentPublication, ContentPublicationContentState.Published, stateChangedBy)); }