private void DeleteDraftCore(DeleteContentDraft c, ContentOperation operation) { operation.MustHavePermission(Permissions.AppContentsVersionDelete); operation.MustDeleteDraft(); DeleteDraft(c); }
public void CanDeleteDraft_should_not_throw_exception() { var content = CreateDraftContent(Status.Draft); var command = new DeleteContentDraft(); GuardContent.CanDeleteDraft(command, content); }
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)); }
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)); }
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."); } }
public static void CanDeleteDraft(DeleteContentDraft command, ContentState content) { Guard.NotNull(command, nameof(command)); if (content.NewStatus == null) { throw new DomainException(T.Get("contents.draftToDeleteNotFound")); } }
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)); }
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")); } }
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)); }
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."); } }
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()) ); }
private void DeleteDraft(DeleteContentDraft command) { Raise(command, new ContentDraftDeleted()); }