Exemplo n.º 1
0
        public static async Task CanCreate(ISchemaEntity schema, IContentWorkflow contentWorkflow, CreateContent command)
        {
            Guard.NotNull(command, nameof(command));

            if (schema.SchemaDef.IsSingleton && command.ContentId != schema.Id)
            {
                throw new DomainException("Singleton content cannot be created.");
            }

            if (command.Publish && !await contentWorkflow.CanPublishOnCreateAsync(schema, command.Data, command.User))
            {
                throw new DomainException("Content workflow prevents publishing.");
            }

            Validate.It(() => "Cannot created content.", e =>
            {
                ValidateData(command, e);
            });
        }
Exemplo n.º 2
0
        public static async Task CanCreate(CreateContent command, IContentWorkflow contentWorkflow, ISchemaEntity schema)
        {
            Guard.NotNull(command, nameof(command));

            if (schema.SchemaDef.IsSingleton && command.ContentId != schema.Id)
            {
                throw new DomainException(T.Get("contents.singletonNotCreatable"));
            }

            if (command.Publish && !await contentWorkflow.CanPublishOnCreateAsync(schema, command.Data, command.User))
            {
                throw new DomainException(T.Get("contents.workflowErorPublishing"));
            }

            Validate.It(e =>
            {
                ValidateData(command, e);
            });
        }
Exemplo n.º 3
0
 private void SetupCanCreatePublish(ISchemaEntity schema, bool canCreate)
 {
     A.CallTo(() => contentWorkflow.CanPublishOnCreateAsync(schema, A <NamedContentData> ._, user))
     .Returns(canCreate);
 }
Exemplo n.º 4
0
 private void SetupCanCreatePublish(bool canCreate)
 {
     A.CallTo(() => workflow.CanPublishOnCreateAsync(schema, A <ContentData> ._, user))
     .Returns(canCreate);
 }