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 && await operation.ShouldValidateAsync(c.Status)) { await operation.ValidateContentAndInputAsync(Snapshot.Data, c.OptimizeValidation, true); } ChangeStatus(c); }