Exemplo n.º 1
0
 public static void MustHaveData(this OperationContext context, ContentData?data)
 {
     if (data == null)
     {
         context.AddError(Not.Defined(nameof(data)), nameof(data)).ThrowOnErrors();
     }
 }
Exemplo n.º 2
0
        public static async Task CheckStatusAsync(this OperationContext context, Status status)
        {
            if (!context.SchemaDef.IsSingleton())
            {
                var workflow = GetWorkflow(context);

                var statusInfo = await workflow.GetInfoAsync(context.Content, status);

                if (statusInfo == null)
                {
                    context.AddError(T.Get("contents.statusNotValid"), nameof(status));
                    context.ThrowOnErrors();
                }
            }
        }
Exemplo n.º 3
0
        public static async Task CheckTransitionAsync(this OperationContext context, Status status)
        {
            if (!context.SchemaDef.IsSingleton())
            {
                var workflow = GetWorkflow(context);

                var oldStatus = context.Content.EditingStatus();

                if (!await workflow.CanMoveToAsync(context.Content, oldStatus, status, context.User))
                {
                    var values = new { oldStatus, newStatus = status };

                    context.AddError(T.Get("contents.statusTransitionNotAllowed", values), nameof(status));
                    context.ThrowOnErrors();
                }
            }
        }