Browse Source

Synced calls

pull/206/head
Sebastian Stehle 8 years ago
parent
commit
84fb381380
  1. 20
      src/Squidex.Domain.Apps.Entities/Apps/AppCommandMiddleware.cs
  2. 8
      src/Squidex.Domain.Apps.Entities/Assets/AssetCommandMiddleware.cs
  3. 10
      src/Squidex.Domain.Apps.Entities/Rules/RuleCommandMiddleware.cs
  4. 30
      src/Squidex.Domain.Apps.Entities/Schemas/SchemaCommandMiddleware.cs

20
src/Squidex.Domain.Apps.Entities/Apps/AppCommandMiddleware.cs

@ -48,7 +48,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
protected Task On(CreateApp command, CommandContext context) protected Task On(CreateApp command, CommandContext context)
{ {
return handler.CreateAsync<AppDomainObject>(context, async a => return handler.CreateSyncedAsync<AppDomainObject>(context, async a =>
{ {
await GuardApp.CanCreate(command, appProvider); await GuardApp.CanCreate(command, appProvider);
@ -60,7 +60,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
protected Task On(AssignContributor command, CommandContext context) protected Task On(AssignContributor command, CommandContext context)
{ {
return handler.UpdateAsync<AppDomainObject>(context, async a => return handler.handler.UpdateSyncedAsync<AppDomainObject>(context, async a =>
{ {
await GuardAppContributors.CanAssign(a.State.Contributors, command, userResolver, appPlansProvider.GetPlan(a.State.Plan?.PlanId)); await GuardAppContributors.CanAssign(a.State.Contributors, command, userResolver, appPlansProvider.GetPlan(a.State.Plan?.PlanId));
@ -70,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
protected Task On(RemoveContributor command, CommandContext context) protected Task On(RemoveContributor command, CommandContext context)
{ {
return handler.UpdateAsync<AppDomainObject>(context, a => return handler.handler.UpdateSyncedAsync<AppDomainObject>(context, a =>
{ {
GuardAppContributors.CanRemove(a.State.Contributors, command); GuardAppContributors.CanRemove(a.State.Contributors, command);
@ -80,7 +80,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
protected Task On(AttachClient command, CommandContext context) protected Task On(AttachClient command, CommandContext context)
{ {
return handler.UpdateAsync<AppDomainObject>(context, a => return handler.handler.UpdateSyncedAsync<AppDomainObject>(context, a =>
{ {
GuardAppClients.CanAttach(a.State.Clients, command); GuardAppClients.CanAttach(a.State.Clients, command);
@ -90,7 +90,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
protected Task On(UpdateClient command, CommandContext context) protected Task On(UpdateClient command, CommandContext context)
{ {
return handler.UpdateAsync<AppDomainObject>(context, a => return handler.handler.UpdateSyncedAsync<AppDomainObject>(context, a =>
{ {
GuardAppClients.CanUpdate(a.State.Clients, command); GuardAppClients.CanUpdate(a.State.Clients, command);
@ -100,7 +100,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
protected Task On(RevokeClient command, CommandContext context) protected Task On(RevokeClient command, CommandContext context)
{ {
return handler.UpdateAsync<AppDomainObject>(context, a => return handler.handler.UpdateSyncedAsync<AppDomainObject>(context, a =>
{ {
GuardAppClients.CanRevoke(a.State.Clients, command); GuardAppClients.CanRevoke(a.State.Clients, command);
@ -110,7 +110,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
protected Task On(AddLanguage command, CommandContext context) protected Task On(AddLanguage command, CommandContext context)
{ {
return handler.UpdateAsync<AppDomainObject>(context, a => return handler.handler.UpdateSyncedAsync<AppDomainObject>(context, a =>
{ {
GuardAppLanguages.CanAdd(a.State.LanguagesConfig, command); GuardAppLanguages.CanAdd(a.State.LanguagesConfig, command);
@ -120,7 +120,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
protected Task On(RemoveLanguage command, CommandContext context) protected Task On(RemoveLanguage command, CommandContext context)
{ {
return handler.UpdateAsync<AppDomainObject>(context, a => return handler.handler.UpdateSyncedAsync<AppDomainObject>(context, a =>
{ {
GuardAppLanguages.CanRemove(a.State.LanguagesConfig, command); GuardAppLanguages.CanRemove(a.State.LanguagesConfig, command);
@ -130,7 +130,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
protected Task On(UpdateLanguage command, CommandContext context) protected Task On(UpdateLanguage command, CommandContext context)
{ {
return handler.UpdateAsync<AppDomainObject>(context, a => return handler.handler.UpdateSyncedAsync<AppDomainObject>(context, a =>
{ {
GuardAppLanguages.CanUpdate(a.State.LanguagesConfig, command); GuardAppLanguages.CanUpdate(a.State.LanguagesConfig, command);
@ -140,7 +140,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
protected Task On(ChangePlan command, CommandContext context) protected Task On(ChangePlan command, CommandContext context)
{ {
return handler.UpdateAsync<AppDomainObject>(context, async a => return handler.handler.UpdateSyncedAsync<AppDomainObject>(context, async a =>
{ {
GuardApp.CanChangePlan(command, a.State.Plan, appPlansProvider); GuardApp.CanChangePlan(command, a.State.Plan, appPlansProvider);

8
src/Squidex.Domain.Apps.Entities/Assets/AssetCommandMiddleware.cs

@ -42,7 +42,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
command.ImageInfo = await assetThumbnailGenerator.GetImageInfoAsync(command.File.OpenRead()); command.ImageInfo = await assetThumbnailGenerator.GetImageInfoAsync(command.File.OpenRead());
try try
{ {
var asset = await handler.CreateAsync<AssetDomainObject>(context, async a => var asset = await handler.CreateSyncedAsync<AssetDomainObject>(context, async a =>
{ {
GuardAsset.CanCreate(command); GuardAsset.CanCreate(command);
@ -67,7 +67,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
try try
{ {
var asset = await handler.UpdateAsync<AssetDomainObject>(context, async a => var asset = await handler.handler.UpdateSyncedAsync<AssetDomainObject>(context, async a =>
{ {
GuardAsset.CanUpdate(command); GuardAsset.CanUpdate(command);
@ -88,7 +88,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
protected Task On(RenameAsset command, CommandContext context) protected Task On(RenameAsset command, CommandContext context)
{ {
return handler.UpdateAsync<AssetDomainObject>(context, a => return handler.handler.UpdateSyncedAsync<AssetDomainObject>(context, a =>
{ {
GuardAsset.CanRename(command, a.State.FileName); GuardAsset.CanRename(command, a.State.FileName);
@ -98,7 +98,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
protected Task On(DeleteAsset command, CommandContext context) protected Task On(DeleteAsset command, CommandContext context)
{ {
return handler.UpdateAsync<AssetDomainObject>(context, a => return handler.handler.UpdateSyncedAsync<AssetDomainObject>(context, a =>
{ {
GuardAsset.CanDelete(command); GuardAsset.CanDelete(command);

10
src/Squidex.Domain.Apps.Entities/Rules/RuleCommandMiddleware.cs

@ -33,7 +33,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
protected Task On(CreateRule command, CommandContext context) protected Task On(CreateRule command, CommandContext context)
{ {
return handler.CreateAsync<RuleDomainObject>(context, async w => return handler.CreateSyncedAsync<RuleDomainObject>(context, async w =>
{ {
await GuardRule.CanCreate(command, appProvider); await GuardRule.CanCreate(command, appProvider);
@ -43,7 +43,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
protected Task On(UpdateRule command, CommandContext context) protected Task On(UpdateRule command, CommandContext context)
{ {
return handler.UpdateAsync<RuleDomainObject>(context, async c => return handler.handler.UpdateSyncedAsync<RuleDomainObject>(context, async c =>
{ {
await GuardRule.CanUpdate(command, appProvider); await GuardRule.CanUpdate(command, appProvider);
@ -53,7 +53,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
protected Task On(EnableRule command, CommandContext context) protected Task On(EnableRule command, CommandContext context)
{ {
return handler.UpdateAsync<RuleDomainObject>(context, r => return handler.handler.UpdateSyncedAsync<RuleDomainObject>(context, r =>
{ {
GuardRule.CanEnable(command, r.State.RuleDef); GuardRule.CanEnable(command, r.State.RuleDef);
@ -63,7 +63,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
protected Task On(DisableRule command, CommandContext context) protected Task On(DisableRule command, CommandContext context)
{ {
return handler.UpdateAsync<RuleDomainObject>(context, r => return handler.handler.UpdateSyncedAsync<RuleDomainObject>(context, r =>
{ {
GuardRule.CanDisable(command, r.State.RuleDef); GuardRule.CanDisable(command, r.State.RuleDef);
@ -73,7 +73,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
protected Task On(DeleteRule command, CommandContext context) protected Task On(DeleteRule command, CommandContext context)
{ {
return handler.UpdateAsync<RuleDomainObject>(context, c => return handler.handler.UpdateSyncedAsync<RuleDomainObject>(context, c =>
{ {
GuardRule.CanDelete(command); GuardRule.CanDelete(command);

30
src/Squidex.Domain.Apps.Entities/Schemas/SchemaCommandMiddleware.cs

@ -35,7 +35,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(CreateSchema command, CommandContext context) protected Task On(CreateSchema command, CommandContext context)
{ {
return handler.CreateAsync<SchemaDomainObject>(context, async s => return handler.CreateSyncedAsync<SchemaDomainObject>(context, async s =>
{ {
await GuardSchema.CanCreate(command, appProvider); await GuardSchema.CanCreate(command, appProvider);
@ -47,7 +47,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(AddField command, CommandContext context) protected Task On(AddField command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchemaField.CanAdd(s.State.SchemaDef, command); GuardSchemaField.CanAdd(s.State.SchemaDef, command);
@ -59,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(DeleteField command, CommandContext context) protected Task On(DeleteField command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchemaField.CanDelete(s.State.SchemaDef, command); GuardSchemaField.CanDelete(s.State.SchemaDef, command);
@ -69,7 +69,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(LockField command, CommandContext context) protected Task On(LockField command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchemaField.CanLock(s.State.SchemaDef, command); GuardSchemaField.CanLock(s.State.SchemaDef, command);
@ -79,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(HideField command, CommandContext context) protected Task On(HideField command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchemaField.CanHide(s.State.SchemaDef, command); GuardSchemaField.CanHide(s.State.SchemaDef, command);
@ -89,7 +89,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(ShowField command, CommandContext context) protected Task On(ShowField command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchemaField.CanShow(s.State.SchemaDef, command); GuardSchemaField.CanShow(s.State.SchemaDef, command);
@ -99,7 +99,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(DisableField command, CommandContext context) protected Task On(DisableField command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchemaField.CanDisable(s.State.SchemaDef, command); GuardSchemaField.CanDisable(s.State.SchemaDef, command);
@ -109,7 +109,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(EnableField command, CommandContext context) protected Task On(EnableField command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchemaField.CanEnable(s.State.SchemaDef, command); GuardSchemaField.CanEnable(s.State.SchemaDef, command);
@ -119,7 +119,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(UpdateField command, CommandContext context) protected Task On(UpdateField command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchemaField.CanUpdate(s.State.SchemaDef, command); GuardSchemaField.CanUpdate(s.State.SchemaDef, command);
@ -129,7 +129,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(ReorderFields command, CommandContext context) protected Task On(ReorderFields command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchema.CanReorder(s.State.SchemaDef, command); GuardSchema.CanReorder(s.State.SchemaDef, command);
@ -139,7 +139,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(UpdateSchema command, CommandContext context) protected Task On(UpdateSchema command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchema.CanUpdate(s.State.SchemaDef, command); GuardSchema.CanUpdate(s.State.SchemaDef, command);
@ -149,7 +149,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(PublishSchema command, CommandContext context) protected Task On(PublishSchema command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchema.CanPublish(s.State.SchemaDef, command); GuardSchema.CanPublish(s.State.SchemaDef, command);
@ -159,7 +159,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(UnpublishSchema command, CommandContext context) protected Task On(UnpublishSchema command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchema.CanUnpublish(s.State.SchemaDef, command); GuardSchema.CanUnpublish(s.State.SchemaDef, command);
@ -169,7 +169,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(ConfigureScripts command, CommandContext context) protected Task On(ConfigureScripts command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchema.CanConfigureScripts(s.State.SchemaDef, command); GuardSchema.CanConfigureScripts(s.State.SchemaDef, command);
@ -179,7 +179,7 @@ namespace Squidex.Domain.Apps.Entities.State.SchemaDefs
protected Task On(DeleteSchema command, CommandContext context) protected Task On(DeleteSchema command, CommandContext context)
{ {
return handler.UpdateAsync<SchemaDomainObject>(context, s => return handler.handler.UpdateSyncedAsync<SchemaDomainObject>(context, s =>
{ {
GuardSchema.CanDelete(s.State.SchemaDef, command); GuardSchema.CanDelete(s.State.SchemaDef, command);

Loading…
Cancel
Save