public static void MustHaveData(this ContentOperation operation, ContentData?data) { if (data == null) { operation.AddError(Not.Defined(nameof(data)), nameof(data)); } operation.ThrowOnErrors(); }
public static async Task CheckStatusAsync(this ContentOperation operation, Status status) { if (operation.SchemaDef.Type != SchemaType.Singleton) { var workflow = GetWorkflow(operation); var statusInfo = await workflow.GetInfoAsync(operation.Snapshot, status); if (statusInfo == null) { operation.AddError(T.Get("contents.statusNotValid"), nameof(status)); operation.ThrowOnErrors(); } } }
public static async Task CheckTransitionAsync(this ContentOperation operation, Status status) { if (operation.SchemaDef.Type != SchemaType.Singleton) { var workflow = GetWorkflow(operation); var oldStatus = operation.Snapshot.EditingStatus(); if (!await workflow.CanMoveToAsync(operation.Snapshot, oldStatus, status, operation.User)) { var values = new { oldStatus, newStatus = status }; operation.AddError(T.Get("contents.statusTransitionNotAllowed", values), nameof(status)); operation.ThrowOnErrors(); } } }