Ejemplo n.º 1
0
        private void DeleteDraftCore(DeleteContentDraft c, ContentOperation operation)
        {
            operation.MustHavePermission(Permissions.AppContentsVersionDelete);
            operation.MustDeleteDraft();

            DeleteDraft(c);
        }
Ejemplo n.º 2
0
        public void CanDeleteDraft_should_not_throw_exception()
        {
            var content = CreateDraftContent(Status.Draft);
            var command = new DeleteContentDraft();

            GuardContent.CanDeleteDraft(command, content);
        }
Ejemplo n.º 3
0
        public void CanDeleteDraft_should_throw_exception_if_no_draft_found()
        {
            CreateSchema(false);

            var content = new ContentState();
            var command = new DeleteContentDraft();

            Assert.Throws <DomainException>(() => GuardContent.CanDeleteDraft(command, content));
        }
Ejemplo n.º 4
0
        public void CanDeleteDraft_should_throw_exception_if_singleton()
        {
            var schema = CreateSchema(true);

            var content = CreateDraftContent(Status.Draft);
            var command = new DeleteContentDraft();

            Assert.Throws <DomainException>(() => GuardContent.CanDeleteDraft(command, schema, content));
        }
Ejemplo n.º 5
0
        public static void CanDeleteDraft(DeleteContentDraft command, ContentState content)
        {
            Guard.NotNull(command, nameof(command));

            if (content.NewStatus == null)
            {
                throw new DomainException("There is nothing to delete.");
            }
        }
Ejemplo n.º 6
0
        public static void CanDeleteDraft(DeleteContentDraft command, ContentState content)
        {
            Guard.NotNull(command, nameof(command));

            if (content.NewStatus == null)
            {
                throw new DomainException(T.Get("contents.draftToDeleteNotFound"));
            }
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> DeleteVersion(string app, string name, DomainId id)
        {
            var command = new DeleteContentDraft {
                ContentId = id
            };

            var response = await InvokeCommandAsync(command);

            return(Ok(response));
        }
Ejemplo n.º 8
0
        public static void CanDeleteDraft(DeleteContentDraft command, IContentEntity content)
        {
            Guard.NotNull(command, nameof(command));

            CheckPermission(content, command, Permissions.AppContentsVersionDelete);

            if (content.NewStatus == null)
            {
                throw new DomainException(T.Get("contents.draftToDeleteNotFound"));
            }
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> DeleteVersion(string app, string name, Guid id)
        {
            await contentQuery.GetSchemaOrThrowAsync(Context, name);

            var command = new DeleteContentDraft {
                ContentId = id
            };

            var response = await InvokeCommandAsync(command);

            return(Ok(response));
        }
Ejemplo n.º 10
0
        public static void CanDeleteDraft(DeleteContentDraft command, ISchemaEntity schema, ContentState content)
        {
            Guard.NotNull(command);

            if (schema.SchemaDef.IsSingleton)
            {
                throw new DomainException("Singleton content cannot be updated.");
            }

            if (content.NewStatus == null)
            {
                throw new DomainException("There is nothing to delete.");
            }
        }
Ejemplo n.º 11
0
        public async Task DeleteDraft_should_create_events_and_delete_new_version()
        {
            var command = new DeleteContentDraft();

            await ExecuteCreateAsync();
            await ExecutePublishAsync();
            await ExecuteCreateDraftAsync();

            var result = await PublishAsync(command);

            result.ShouldBeEquivalent(new EntitySavedResult(3));

            Assert.Null(sut.Snapshot.NewVersion);

            LastEvents
            .ShouldHaveSameEvents(
                CreateContentEvent(new ContentDraftDeleted())
                );
        }
Ejemplo n.º 12
0
 private void DeleteDraft(DeleteContentDraft command)
 {
     Raise(command, new ContentDraftDeleted());
 }