protected override Task <object> ExecuteAsync(IAggregateCommand command) { switch (command) { case CreateComment createComment: return(UpsertAsync(createComment, c => { GuardComments.CanCreate(c); Create(c); return EntityCreatedResult.Create(createComment.CommentId, Version); })); case UpdateComment updateComment: return(UpsertAsync(updateComment, c => { GuardComments.CanUpdate(events, c); Update(c); })); case DeleteComment deleteComment: return(UpsertAsync(deleteComment, c => { GuardComments.CanDelete(events, c); Delete(c); })); default: throw new NotSupportedException(); } }
public CommandRequest(IAggregateCommand command, string culture, string cultureUI) { Command = command; Culture = culture; CultureUI = cultureUI; }
/// <summary> /// Execute a Sub-Command of the current command being executed. /// </summary> /// <param name="baseCommand"></param> /// <param name="subCommand"></param> /// <returns></returns> public bool ExecuteSubCommand(IAggregateCommand baseCommand, ICommand subCommand) { subCommand.ProcessorContext = ProcessorContext; baseCommand.AggregateCommands.Push(subCommand); try { ProcessorContext.PreExecute(subCommand); subCommand.Execute(this); } catch (Exception e) { if (subCommand.RequiresRollback) { if (!_contextRolledback) { ProcessorContext.Rollback(); _contextRolledback = true; } // Real rollback happens when the Execute fails FailureReason = String.Format("{0}: {1}", e.GetType().Name, e.Message); Platform.Log(LogLevel.Error, e, "Unexpected error when executing command: {0}", subCommand.Description); FailureException = e; return(false); } Platform.Log(LogLevel.Warn, e, "Unexpected exception on command {0} that doesn't require rollback", subCommand.Description); baseCommand.AggregateCommands.Pop(); // Pop it off the stack, since it failed. } return(true); }
protected override Task <object> ExecuteAsync(IAggregateCommand command) { VerifyNotDeleted(); switch (command) { case CreateAsset createRule: return(CreateReturnAsync(createRule, async c => { GuardAsset.CanCreate(c); c.Tags = await tagService.NormalizeTagsAsync(c.AppId.Id, TagGroups.Assets, c.Tags, Snapshot.Tags); Create(c); return new AssetSavedResult(Version, Snapshot.FileVersion); })); case UpdateAsset updateRule: return(UpdateAsync(updateRule, c => { GuardAsset.CanUpdate(c); Update(c); return new AssetSavedResult(Version, Snapshot.FileVersion); })); case TagAsset tagAsset: return(UpdateAsync(tagAsset, async c => { GuardAsset.CanTag(c); c.Tags = await tagService.NormalizeTagsAsync(Snapshot.AppId.Id, TagGroups.Assets, c.Tags, Snapshot.Tags); Tag(c); })); case DeleteAsset deleteAsset: return(UpdateAsync(deleteAsset, async c => { GuardAsset.CanDelete(c); await tagService.NormalizeTagsAsync(Snapshot.AppId.Id, TagGroups.Assets, null, Snapshot.Tags); Delete(c); })); case RenameAsset renameAsset: return(UpdateAsync(renameAsset, c => { GuardAsset.CanRename(c, Snapshot.FileName); Rename(c); })); default: throw new NotSupportedException(); } }
public override Task <object?> ExecuteAsync(IAggregateCommand command) { switch (command) { case CreateRule createRule: return(CreateReturnAsync(createRule, async c => { await GuardRule.CanCreate(c, appProvider); Create(c); return Snapshot; })); case UpdateRule updateRule: return(UpdateReturnAsync(updateRule, async c => { await GuardRule.CanUpdate(c, Snapshot.AppId.Id, appProvider); Update(c); return Snapshot; })); case EnableRule enableRule: return(UpdateReturn(enableRule, c => { GuardRule.CanEnable(c); Enable(c); return Snapshot; })); case DisableRule disableRule: return(UpdateReturn(disableRule, c => { GuardRule.CanDisable(c); Disable(c); return Snapshot; })); case DeleteRule deleteRule: return(Update(deleteRule, c => { GuardRule.CanDelete(deleteRule); Delete(c); })); case TriggerRule triggerRule: return(Trigger(triggerRule)); default: throw new NotSupportedException(); } }
public void StorePendingCommand(IAggregateCommand command) { var cmd = new PendingCommand { AggregateId = command.AggregateId, CommandId = command.Identity, Identity = Guid.NewGuid(), CommandData = this.serializer.SerializeToString(command), }; this.Save(cmd); }
protected override Task <object> ExecuteAsync(IAggregateCommand command) { VerifyNotDeleted(); switch (command) { case CreateRule createRule: return(CreateAsync(createRule, async c => { await GuardRule.CanCreate(c, appProvider); Create(c); })); case UpdateRule updateRule: return(UpdateAsync(updateRule, async c => { await GuardRule.CanUpdate(c, Snapshot.AppId.Id, appProvider); Update(c); })); case EnableRule enableRule: return(UpdateAsync(enableRule, c => { GuardRule.CanEnable(c, Snapshot.RuleDef); Enable(c); })); case DisableRule disableRule: return(UpdateAsync(disableRule, c => { GuardRule.CanDisable(c, Snapshot.RuleDef); Disable(c); })); case DeleteRule deleteRule: return(UpdateAsync(deleteRule, c => { GuardRule.CanDelete(deleteRule); Delete(c); })); default: throw new NotSupportedException(); } }
public override Task <object?> ExecuteAsync(IAggregateCommand command) { VerifyNotDeleted(); switch (command) { case CreateContent createContent: return(CreateReturnAsync(createContent, async c => { await LoadContext(c.AppId, c.SchemaId, c, c.OptimizeValidation); await GuardContent.CanCreate(context.Schema, contentWorkflow, c); var status = await contentWorkflow.GetInitialStatusAsync(context.Schema); if (!c.DoNotValidate) { await context.ValidateInputAsync(c.Data); } if (!c.DoNotScript) { c.Data = await context.ExecuteScriptAndTransformAsync(s => s.Create, new ScriptVars { Operation = "Create", Data = c.Data, Status = status, StatusOld = default }); } await context.GenerateDefaultValuesAsync(c.Data); if (!c.DoNotValidate) { await context.ValidateContentAsync(c.Data); } if (!c.DoNotScript && c.Publish) { await context.ExecuteScriptAsync(s => s.Change, new ScriptVars { Operation = "Published", Data = c.Data, Status = Status.Published, StatusOld = default });
public override Task <object?> ExecuteAsync(IAggregateCommand command) { VerifyNotDeleted(); VerifyCommand(command); switch (command) { case CreateAssetFolder createAssetFolder: return(CreateReturnAsync(createAssetFolder, async c => { await GuardAssetFolder.CanCreate(c, assetQuery); Create(c); return Snapshot; })); case MoveAssetFolder moveAssetFolder: return(UpdateReturnAsync(moveAssetFolder, async c => { await GuardAssetFolder.CanMove(c, assetQuery, Snapshot.Id, Snapshot.ParentId); Move(c); return Snapshot; })); case RenameAssetFolder renameAssetFolder: return(UpdateReturn(renameAssetFolder, c => { GuardAssetFolder.CanRename(c); Rename(c); return Snapshot; })); case DeleteAssetFolder deleteAssetFolder: return(Update(deleteAssetFolder, c => { GuardAssetFolder.CanDelete(c); Delete(c); })); default: throw new NotSupportedException(); } }
private void Execute(IAggregateRoot aggregate, IAggregateCommand command) { try { if (!MethodExecutor.ExecuteMethodForSingleParam(aggregate, command)) { throw new MissingMethodException(string.Format("Aggregate {0} does not support a method that can be called with {1}", aggregate, command)); } } catch (Exception ex) { Debug.WriteLine("Error executing command\n{0}", ex); throw; } }
protected override Task <object> ExecuteAsync(IAggregateCommand command) { VerifyNotDeleted(); switch (command) { case CreateContent createContent: return(CreateReturnAsync(createContent, async c => { var ctx = await CreateContext(c.AppId.Id, c.SchemaId.Id, c, () => "Failed to create content."); var status = (await contentWorkflow.GetInitialStatusAsync(ctx.Schema)).Status; await GuardContent.CanCreate(ctx.Schema, contentWorkflow, c); c.Data = await ctx.ExecuteScriptAndTransformAsync(s => s.Create, new ScriptContext { Operation = "Create", Data = c.Data, Status = status, StatusOld = default }); await ctx.EnrichAsync(c.Data); if (!c.DoNotValidate) { await ctx.ValidateAsync(c.Data); } if (c.Publish) { await ctx.ExecuteScriptAsync(s => s.Change, new ScriptContext { Operation = "Published", Data = c.Data, Status = Status.Published, StatusOld = status }); } Create(c, status); return Snapshot; }));
public override Task <CommandResult> ExecuteAsync(IAggregateCommand command) { switch (command) { case CreateAssetFolder c: return(CreateReturnAsync(c, async create => { await GuardAssetFolder.CanCreate(create, assetQuery); Create(create); return Snapshot; })); case MoveAssetFolder move: return(UpdateReturnAsync(move, async c => { await GuardAssetFolder.CanMove(c, Snapshot, assetQuery); Move(c); return Snapshot; })); case RenameAssetFolder rename: return(UpdateReturn(rename, c => { GuardAssetFolder.CanRename(c); Rename(c); return Snapshot; })); case DeleteAssetFolder delete: return(Update(delete, c => { GuardAssetFolder.CanDelete(c); Delete(c); })); default: throw new NotSupportedException(); } }
private void VerifyCommand(IAggregateCommand command) { switch (command) { case AssetFolderCommand assetFolderCommand: if (Version >= 0 && ( !assetFolderCommand.AssetFolderId.Equals(Snapshot.Id) || !assetFolderCommand.AppId.Equals(Snapshot.AppId))) { throw new InvalidOperationException(); } break; default: throw new NotSupportedException(); } }
public override Task <object> ExecuteAsync(IAggregateCommand command) { switch (command) { case CreateAsset createRule: return(CreateReturnAsync(createRule, c => { GuardAsset.CanCreate(c); Create(c); return new AssetSavedResult(NewVersion, Snapshot.FileVersion); })); case UpdateAsset updateRule: return(UpdateReturnAsync(updateRule, c => { GuardAsset.CanUpdate(c); Update(c); return new AssetSavedResult(NewVersion, Snapshot.FileVersion); })); case RenameAsset renameAsset: return(UpdateAsync(renameAsset, c => { GuardAsset.CanRename(c, Snapshot.FileName); Rename(c); })); case DeleteAsset deleteAsset: return(UpdateAsync(deleteAsset, c => { GuardAsset.CanDelete(c); Delete(c); })); default: throw new NotSupportedException(); } }
protected override Task <object> ExecuteAsync(IAggregateCommand command) { switch (command) { case CreateAuto createAuto: return(CreateAsync(createAuto, c => { RaiseEvent(new ValueChanged { Value = c.Value }); })); case CreateCustom createCustom: return(CreateReturnAsync(createCustom, c => { RaiseEvent(new ValueChanged { Value = c.Value }); return "CREATED"; })); case UpdateAuto updateAuto: return(UpdateAsync(updateAuto, c => { RaiseEvent(new ValueChanged { Value = c.Value }); })); case UpdateCustom updateCustom: return(UpdateAsync(updateCustom, c => { RaiseEvent(new ValueChanged { Value = c.Value }); return "UPDATED"; })); } return(Task.FromResult <object>(null)); }
/// <summary> /// Static method for rolling back a command that implements <see cref="IAggregateCommand"/> /// </summary> /// <param name="command">The aggregate command to rollback sub-commands for.</param> protected static void RollbackAggregateCommand(IAggregateCommand command) { while (command.AggregateCommands.Count > 0) { ICommand subCommand = command.AggregateCommands.Pop(); try { subCommand.Undo(); } catch (Exception e) { Platform.Log(LogLevel.Error, e, "Unexpected exception rolling back sub command {0}", subCommand.Description); } var aggregateCommand = subCommand as IAggregateCommand; if (aggregateCommand != null) { RollbackAggregateCommand(aggregateCommand); } } }
public override Task <CommandResult> ExecuteAsync(IAggregateCommand command) { switch (command) { case CreateAssetFolder c: return(CreateReturnAsync(c, async create => { await CreateCore(create, c); return Snapshot; })); case MoveAssetFolder move: return(UpdateReturnAsync(move, async c => { await MoveCore(c); return Snapshot; })); case RenameAssetFolder rename: return(UpdateReturnAsync(rename, async c => { await RenameCore(c); return Snapshot; })); case DeleteAssetFolder delete: return(Update(delete, c => { Delete(c); })); default: throw new NotSupportedException(); } }
protected abstract Task <object?> ExecuteAsync(IAggregateCommand command);
public override Task <object?> ExecuteAsync(IAggregateCommand command) { switch (command) { case UpsertContent uspertContent: { if (Version > EtagVersion.Empty) { var updateContent = SimpleMapper.Map(uspertContent, new UpdateContent()); return(ExecuteAsync(updateContent)); } else { var createContent = SimpleMapper.Map(uspertContent, new CreateContent()); return(ExecuteAsync(createContent)); } } case CreateContent createContent: return(CreateReturnAsync(createContent, async c => { await LoadContext(c, c.OptimizeValidation); await GuardContent.CanCreate(c, context.Workflow, context.Schema); var status = await context.GetInitialStatusAsync(); if (!c.DoNotValidate) { await context.ValidateInputAsync(c.Data, createContent.Publish); } if (!c.DoNotScript) { c.Data = await context.ExecuteScriptAndTransformAsync(s => s.Create, new ScriptVars { Operation = "Create", Data = c.Data, Status = status, StatusOld = default }); } await context.GenerateDefaultValuesAsync(c.Data); if (!c.DoNotValidate) { await context.ValidateContentAsync(c.Data); } if (!c.DoNotScript && c.Publish) { c.Data = await context.ExecuteScriptAndTransformAsync(s => s.Change, new ScriptVars { Operation = "Published", Data = c.Data, Status = Status.Published, StatusOld = default });
/// <summary> /// Execute a Sub-Command of the current command being executed. /// </summary> /// <param name="baseCommand"></param> /// <param name="subCommand"></param> /// <returns></returns> public bool ExecuteSubCommand(IAggregateCommand baseCommand, ICommand subCommand) { subCommand.ProcessorContext = ProcessorContext; baseCommand.AggregateCommands.Push(subCommand); try { ProcessorContext.PreExecute(subCommand); subCommand.Execute(this); } catch (Exception e) { if (subCommand.RequiresRollback) { if (!_contextRolledback) { ProcessorContext.Rollback(); _contextRolledback = true; } // Real rollback happens when the Execute fails FailureReason = String.Format("{0}: {1}", e.GetType().Name, e.Message); Platform.Log(LogLevel.Error, e, "Unexpected error when executing command: {0}", subCommand.Description); FailureException = e; return false; } Platform.Log(LogLevel.Warn, e, "Unexpected exception on command {0} that doesn't require rollback", subCommand.Description); baseCommand.AggregateCommands.Pop(); // Pop it off the stack, since it failed. } return true; }
private static J <IAggregateCommand> C(IAggregateCommand command) { return(command.AsJ()); }
protected override Task <object> ExecuteAsync(IAggregateCommand command) { VerifyNotArchived(); switch (command) { case CreateApp createApp: return(CreateReturn(createApp, c => { GuardApp.CanCreate(c); Create(c); return Snapshot; })); case AssignContributor assignContributor: return(UpdateReturnAsync(assignContributor, async c => { await GuardAppContributors.CanAssign(Snapshot.Contributors, Snapshot.Roles, c, userResolver, GetPlan()); AssignContributor(c, !Snapshot.Contributors.ContainsKey(assignContributor.ContributorId)); return Snapshot; })); case RemoveContributor removeContributor: return(UpdateReturn(removeContributor, c => { GuardAppContributors.CanRemove(Snapshot.Contributors, c); RemoveContributor(c); return Snapshot; })); case AttachClient attachClient: return(UpdateReturn(attachClient, c => { GuardAppClients.CanAttach(Snapshot.Clients, c); AttachClient(c); return Snapshot; })); case UpdateClient updateClient: return(UpdateReturn(updateClient, c => { GuardAppClients.CanUpdate(Snapshot.Clients, c, Snapshot.Roles); UpdateClient(c); return Snapshot; })); case RevokeClient revokeClient: return(UpdateReturn(revokeClient, c => { GuardAppClients.CanRevoke(Snapshot.Clients, c); RevokeClient(c); return Snapshot; })); case AddLanguage addLanguage: return(UpdateReturn(addLanguage, c => { GuardAppLanguages.CanAdd(Snapshot.LanguagesConfig, c); AddLanguage(c); return Snapshot; })); case RemoveLanguage removeLanguage: return(UpdateReturn(removeLanguage, c => { GuardAppLanguages.CanRemove(Snapshot.LanguagesConfig, c); RemoveLanguage(c); return Snapshot; })); case UpdateLanguage updateLanguage: return(UpdateReturn(updateLanguage, c => { GuardAppLanguages.CanUpdate(Snapshot.LanguagesConfig, c); UpdateLanguage(c); return Snapshot; })); case AddRole addRole: return(UpdateReturn(addRole, c => { GuardAppRoles.CanAdd(Snapshot.Roles, c); AddRole(c); return Snapshot; })); case DeleteRole deleteRole: return(UpdateReturn(deleteRole, c => { GuardAppRoles.CanDelete(Snapshot.Roles, c, Snapshot.Contributors, Snapshot.Clients); DeleteRole(c); return Snapshot; })); case UpdateRole updateRole: return(UpdateReturn(updateRole, c => { GuardAppRoles.CanUpdate(Snapshot.Roles, c); UpdateRole(c); return Snapshot; })); case AddPattern addPattern: return(UpdateReturn(addPattern, c => { GuardAppPatterns.CanAdd(Snapshot.Patterns, c); AddPattern(c); return Snapshot; })); case DeletePattern deletePattern: return(UpdateReturn(deletePattern, c => { GuardAppPatterns.CanDelete(Snapshot.Patterns, c); DeletePattern(c); return Snapshot; })); case UpdatePattern updatePattern: return(UpdateReturn(updatePattern, c => { GuardAppPatterns.CanUpdate(Snapshot.Patterns, c); UpdatePattern(c); return Snapshot; })); case ChangePlan changePlan: return(UpdateReturnAsync(changePlan, async c => { GuardApp.CanChangePlan(c, Snapshot.Plan, appPlansProvider); if (c.FromCallback) { ChangePlan(c); return null; } else { var result = await appPlansBillingManager.ChangePlanAsync(c.Actor.Identifier, Snapshot.NamedId(), c.PlanId); switch (result) { case PlanChangedResult _: ChangePlan(c); break; case PlanResetResult _: ResetPlan(c); break; } return result; } })); case ArchiveApp archiveApp: return(UpdateAsync(archiveApp, async c => { await appPlansBillingManager.ChangePlanAsync(c.Actor.Identifier, Snapshot.NamedId(), null); ArchiveApp(c); })); default: throw new NotSupportedException(); } }
protected override Task <object> ExecuteAsync(IAggregateCommand command) { VerifyNotDeleted(); switch (command) { case CreateContent createContent: return(CreateReturnAsync(createContent, async c => { GuardContent.CanCreate(c); var operationContext = await CreateContext(c, () => "Failed to create content."); if (c.Publish) { await operationContext.ExecuteScriptAsync(x => x.ScriptChange, "Published"); } await operationContext.ExecuteScriptAndTransformAsync(x => x.ScriptCreate, "Create"); await operationContext.EnrichAsync(); await operationContext.ValidateAsync(); Create(c); return EntityCreatedResult.Create(c.Data, NewVersion); })); case UpdateContent updateContent: return(UpdateReturnAsync(updateContent, async c => { GuardContent.CanUpdate(c); var operationContext = await CreateContext(c, () => "Failed to update content."); await operationContext.ValidateAsync(); await operationContext.ExecuteScriptAndTransformAsync(x => x.ScriptUpdate, "Update"); Update(c); return new ContentDataChangedResult(Snapshot.Data, NewVersion); })); case PatchContent patchContent: return(UpdateReturnAsync(patchContent, async c => { GuardContent.CanPatch(c); var operationContext = await CreateContext(c, () => "Failed to patch content."); await operationContext.ValidatePartialAsync(); await operationContext.ExecuteScriptAndTransformAsync(x => x.ScriptUpdate, "Patch"); Patch(c); return new ContentDataChangedResult(Snapshot.Data, NewVersion); })); case ChangeContentStatus patchContent: return(UpdateAsync(patchContent, async c => { GuardContent.CanChangeContentStatus(Snapshot.Status, c); if (!c.DueTime.HasValue) { var operationContext = await CreateContext(c, () => "Failed to patch content."); await operationContext.ExecuteScriptAsync(x => x.ScriptChange, c.Status); } ChangeStatus(c); })); case DeleteContent deleteContent: return(UpdateAsync(deleteContent, async c => { GuardContent.CanDelete(c); var operationContext = await CreateContext(c, () => "Failed to delete content."); await operationContext.ExecuteScriptAsync(x => x.ScriptDelete, "Delete"); Delete(c); })); default: throw new NotSupportedException(); } }
protected static J <IAggregateCommand> J(IAggregateCommand command) { return(command.AsJ()); }
public abstract Task <object?> ExecuteAsync(IAggregateCommand command);
public override Task <object> ExecuteAsync(IAggregateCommand command) { switch (command) { case CreateApp createApp: return(CreateAsync(createApp, async c => { await GuardApp.CanCreate(c, appProvider); Create(c); })); case AssignContributor assigneContributor: return(UpdateAsync(assigneContributor, async c => { await GuardAppContributors.CanAssign(Snapshot.Contributors, c, userResolver, appPlansProvider.GetPlan(Snapshot.Plan?.PlanId)); AssignContributor(c); })); case RemoveContributor removeContributor: return(UpdateAsync(removeContributor, c => { GuardAppContributors.CanRemove(Snapshot.Contributors, c); RemoveContributor(c); })); case AttachClient attachClient: return(UpdateAsync(attachClient, c => { GuardAppClients.CanAttach(Snapshot.Clients, c); AttachClient(c); })); case UpdateClient updateClient: return(UpdateAsync(updateClient, c => { GuardAppClients.CanUpdate(Snapshot.Clients, c); UpdateClient(c); })); case RevokeClient revokeClient: return(UpdateAsync(revokeClient, c => { GuardAppClients.CanRevoke(Snapshot.Clients, c); RevokeClient(c); })); case AddLanguage addLanguage: return(UpdateAsync(addLanguage, c => { GuardAppLanguages.CanAdd(Snapshot.LanguagesConfig, c); AddLanguage(c); })); case RemoveLanguage removeLanguage: return(UpdateAsync(removeLanguage, c => { GuardAppLanguages.CanRemove(Snapshot.LanguagesConfig, c); RemoveLanguage(c); })); case UpdateLanguage updateLanguage: return(UpdateAsync(updateLanguage, c => { GuardAppLanguages.CanUpdate(Snapshot.LanguagesConfig, c); UpdateLanguage(c); })); case AddPattern addPattern: return(UpdateAsync(addPattern, c => { GuardAppPattern.CanAdd(Snapshot.Patterns, c); AddPattern(c); })); case DeletePattern deletePattern: return(UpdateAsync(deletePattern, c => { GuardAppPattern.CanDelete(Snapshot.Patterns, c); DeletePattern(c); })); case UpdatePattern updatePattern: return(UpdateAsync(updatePattern, c => { GuardAppPattern.CanUpdate(Snapshot.Patterns, c); UpdatePattern(c); })); case ChangePlan changePlan: return(UpdateReturnAsync(changePlan, async c => { GuardApp.CanChangePlan(c, Snapshot.Plan, appPlansProvider); if (c.FromCallback) { ChangePlan(c); return null; } else { var result = await appPlansBillingManager.ChangePlanAsync(c.Actor.Identifier, Snapshot.Id, Snapshot.Name, c.PlanId); if (result is PlanChangedResult) { ChangePlan(c); } return result; } })); default: throw new NotSupportedException(); } }
protected override Task <object> ExecuteAsync(IAggregateCommand command) { VerifyNotDeleted(); switch (command) { case CreateSchema createSchema: return(CreateAsync(createSchema, async c => { await GuardSchema.CanCreate(c, appProvider); Create(c); })); case AddField addField: return(UpdateReturnAsync(addField, c => { GuardSchemaField.CanAdd(Snapshot.SchemaDef, c); Add(c); return EntityCreatedResult.Create(Snapshot.SchemaDef.FieldsById.Values.First(x => x.Name == addField.Name).Id, NewVersion); })); case DeleteField deleteField: return(UpdateAsync(deleteField, c => { GuardSchemaField.CanDelete(Snapshot.SchemaDef, deleteField); DeleteField(c); })); case LockField lockField: return(UpdateAsync(lockField, c => { GuardSchemaField.CanLock(Snapshot.SchemaDef, lockField); LockField(c); })); case HideField hideField: return(UpdateAsync(hideField, c => { GuardSchemaField.CanHide(Snapshot.SchemaDef, c); HideField(c); })); case ShowField showField: return(UpdateAsync(showField, c => { GuardSchemaField.CanShow(Snapshot.SchemaDef, c); ShowField(c); })); case DisableField disableField: return(UpdateAsync(disableField, c => { GuardSchemaField.CanDisable(Snapshot.SchemaDef, c); DisableField(c); })); case EnableField enableField: return(UpdateAsync(enableField, c => { GuardSchemaField.CanEnable(Snapshot.SchemaDef, c); EnableField(c); })); case UpdateField updateField: return(UpdateAsync(updateField, c => { GuardSchemaField.CanUpdate(Snapshot.SchemaDef, c); UpdateField(c); })); case ReorderFields reorderFields: return(UpdateAsync(reorderFields, c => { GuardSchema.CanReorder(Snapshot.SchemaDef, c); Reorder(c); })); case UpdateSchema updateSchema: return(UpdateAsync(updateSchema, c => { GuardSchema.CanUpdate(Snapshot.SchemaDef, c); Update(c); })); case PublishSchema publishSchema: return(UpdateAsync(publishSchema, c => { GuardSchema.CanPublish(Snapshot.SchemaDef, c); Publish(c); })); case UnpublishSchema unpublishSchema: return(UpdateAsync(unpublishSchema, c => { GuardSchema.CanUnpublish(Snapshot.SchemaDef, c); Unpublish(c); })); case ConfigureScripts configureScripts: return(UpdateAsync(configureScripts, c => { GuardSchema.CanConfigureScripts(Snapshot.SchemaDef, c); ConfigureScripts(c); })); case DeleteSchema deleteSchema: return(UpdateAsync(deleteSchema, c => { GuardSchema.CanDelete(Snapshot.SchemaDef, c); Delete(c); })); default: throw new NotSupportedException(); } }
public override Task <object?> ExecuteAsync(IAggregateCommand command) { switch (command) { case AddField addField: return(UpdateReturn(addField, c => { GuardSchemaField.CanAdd(c, Snapshot.SchemaDef); Add(c); return Snapshot; })); case CreateSchema createSchema: return(CreateReturn(createSchema, c => { GuardSchema.CanCreate(c); Create(c); return Snapshot; })); case SynchronizeSchema synchronizeSchema: return(UpdateReturn(synchronizeSchema, c => { GuardSchema.CanSynchronize(c); Synchronize(c); return Snapshot; })); case DeleteField deleteField: return(UpdateReturn(deleteField, c => { GuardSchemaField.CanDelete(deleteField, Snapshot.SchemaDef); DeleteField(c); return Snapshot; })); case LockField lockField: return(UpdateReturn(lockField, c => { GuardSchemaField.CanLock(lockField, Snapshot.SchemaDef); LockField(c); return Snapshot; })); case HideField hideField: return(UpdateReturn(hideField, c => { GuardSchemaField.CanHide(c, Snapshot.SchemaDef); HideField(c); return Snapshot; })); case ShowField showField: return(UpdateReturn(showField, c => { GuardSchemaField.CanShow(c, Snapshot.SchemaDef); ShowField(c); return Snapshot; })); case DisableField disableField: return(UpdateReturn(disableField, c => { GuardSchemaField.CanDisable(c, Snapshot.SchemaDef); DisableField(c); return Snapshot; })); case EnableField enableField: return(UpdateReturn(enableField, c => { GuardSchemaField.CanEnable(c, Snapshot.SchemaDef); EnableField(c); return Snapshot; })); case UpdateField updateField: return(UpdateReturn(updateField, c => { GuardSchemaField.CanUpdate(c, Snapshot.SchemaDef); UpdateField(c); return Snapshot; })); case ReorderFields reorderFields: return(UpdateReturn(reorderFields, c => { GuardSchema.CanReorder(c, Snapshot.SchemaDef); Reorder(c); return Snapshot; })); case UpdateSchema updateSchema: return(UpdateReturn(updateSchema, c => { GuardSchema.CanUpdate(c); Update(c); return Snapshot; })); case PublishSchema publishSchema: return(UpdateReturn(publishSchema, c => { GuardSchema.CanPublish(c); Publish(c); return Snapshot; })); case UnpublishSchema unpublishSchema: return(UpdateReturn(unpublishSchema, c => { GuardSchema.CanUnpublish(c); Unpublish(c); return Snapshot; })); case ConfigureFieldRules configureFieldRules: return(UpdateReturn(configureFieldRules, c => { GuardSchema.CanConfigureFieldRules(c); ConfigureFieldRules(c); return Snapshot; })); case ConfigureScripts configureScripts: return(UpdateReturn(configureScripts, c => { GuardSchema.CanConfigureScripts(c); ConfigureScripts(c); return Snapshot; })); case ChangeCategory changeCategory: return(UpdateReturn(changeCategory, c => { GuardSchema.CanChangeCategory(c); ChangeCategory(c); return Snapshot; })); case ConfigurePreviewUrls configurePreviewUrls: return(UpdateReturn(configurePreviewUrls, c => { GuardSchema.CanConfigurePreviewUrls(c); ConfigurePreviewUrls(c); return Snapshot; })); case ConfigureUIFields configureUIFields: return(UpdateReturn(configureUIFields, c => { GuardSchema.CanConfigureUIFields(c, Snapshot.SchemaDef); ConfigureUIFields(c); return Snapshot; })); case DeleteSchema deleteSchema: return(Update(deleteSchema, c => { GuardSchema.CanDelete(c); Delete(c); })); default: throw new NotSupportedException(); } }