private void DeleteDraftCore(DeleteContentDraft c, ContentOperation operation) { operation.MustHavePermission(Permissions.AppContentsVersionDelete); operation.MustDeleteDraft(); DeleteDraft(c); }
private async Task PatchCore(UpdateContent c, ContentOperation operation) { operation.MustHavePermission(Permissions.AppContentsUpdate); operation.MustHaveData(c.Data); if (!c.DoNotValidate) { await operation.ValidateInputPartialAsync(c.Data, c.OptimizeValidation, Snapshot.IsPublished()); } if (!c.DoNotValidateWorkflow) { await operation.CheckUpdateAsync(); } var newData = c.Data.MergeInto(Snapshot.Data); if (newData.Equals(Snapshot.Data)) { return; } if (!c.DoNotScript) { newData = await operation.ExecuteUpdateScriptAsync(newData); } if (!c.DoNotValidate) { await operation.ValidateContentAsync(newData, c.OptimizeValidation, Snapshot.IsPublished()); } Update(c, newData); }
private async Task CreateDraftCore(CreateContentDraft c, ContentOperation operation) { operation.MustHavePermission(Permissions.AppContentsVersionCreate); operation.MustCreateDraft(); var status = await operation.GetInitialStatusAsync(); CreateDraft(c, status); }
private void CancelChangeCore(CancelContentSchedule c, ContentOperation operation) { operation.MustHavePermission(Permissions.AppContentsChangeStatusCancel); if (Snapshot.ScheduleJob != null) { CancelChangeStatus(c); } }
private async Task ChangeCore(ChangeContentStatus c, ContentOperation operation) { operation.MustHavePermission(Permissions.AppContentsChangeStatus); operation.MustNotChangeSingleton(c.Status); if (c.Status == Snapshot.EditingStatus()) { return; } if (c.DoNotValidateWorkflow) { await operation.CheckStatusAsync(c.Status); } else { await operation.CheckTransitionAsync(c.Status); } if (!c.DoNotScript) { var newData = await operation.ExecuteChangeScriptAsync(c.Status, GetChange(c.Status)); if (!newData.Equals(Snapshot.Data)) { var previousEvent = GetUncomittedEvents().Select(x => x.Payload) .OfType <ContentDataCommand>().FirstOrDefault(); if (previousEvent != null) { previousEvent.Data = newData; } else if (!newData.Equals(Snapshot.Data)) { Update(c, newData); } } } if (c.CheckReferrers && Snapshot.IsPublished()) { await operation.CheckReferrersAsync(); } if (!c.DoNotValidate && c.Status == Status.Published && operation.SchemaDef.Properties.ValidateOnPublish) { await operation.ValidateContentAndInputAsync(Snapshot.Data, c.OptimizeValidation, true); } ChangeStatus(c); }
private async Task DeleteCore(DeleteContent c, ContentOperation operation) { operation.MustHavePermission(Permissions.AppContentsDelete); operation.MustNotDeleteSingleton(); if (!c.DoNotScript) { await operation.ExecuteDeleteScriptAsync(c.Permanent); } if (c.CheckReferrers) { await operation.CheckReferrersAsync(); } Delete(c); }
private async Task ValidateCore(ContentOperation operation) { operation.MustHavePermission(Permissions.AppContentsRead); await operation.ValidateContentAndInputAsync(Snapshot.Data, false, Snapshot.IsPublished()); }