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); }); }
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); }); }
private void SetupCanCreatePublish(ISchemaEntity schema, bool canCreate) { A.CallTo(() => contentWorkflow.CanPublishOnCreateAsync(schema, A <NamedContentData> ._, user)) .Returns(canCreate); }
private void SetupCanCreatePublish(bool canCreate) { A.CallTo(() => workflow.CanPublishOnCreateAsync(schema, A <ContentData> ._, user)) .Returns(canCreate); }