protected Task On(UpdateRule command, CommandContext context) { return(handler.UpdateSyncedAsync <RuleDomainObject>(context, async r => { await GuardRule.CanUpdate(command, appProvider); r.Update(command); })); }
protected async Task On(UpdateAsset command, CommandContext context) { command.ImageInfo = await assetThumbnailGenerator.GetImageInfoAsync(command.File.OpenRead()); try { var asset = await handler.UpdateSyncedAsync <AssetDomainObject>(context, async a => { GuardAsset.CanUpdate(command); a.Update(command); await assetStore.UploadTemporaryAsync(context.ContextId.ToString(), command.File.OpenRead()); context.Complete(new AssetSavedResult(a.Version, a.Snapshot.FileVersion)); }); await assetStore.CopyTemporaryAsync(context.ContextId.ToString(), command.AssetId.ToString(), asset.Snapshot.FileVersion, null); } finally { await assetStore.DeleteTemporaryAsync(context.ContextId.ToString()); } }
protected Task On(AddField command, CommandContext context) { return(handler.UpdateSyncedAsync <SchemaDomainObject>(context, s => { GuardSchemaField.CanAdd(s.Snapshot.SchemaDef, command); s.Add(command); context.Complete(EntityCreatedResult.Create(s.Snapshot.SchemaDef.FieldsById.Values.First(x => x.Name == command.Name).Id, s.Version)); })); }
protected Task On(AssignContributor command, CommandContext context) { return(handler.UpdateSyncedAsync <AppDomainObject>(context, async a => { await GuardAppContributors.CanAssign(a.Snapshot.Contributors, command, userResolver, appPlansProvider.GetPlan(a.Snapshot.Plan?.PlanId)); a.AssignContributor(command); })); }
public static Task <T> UpdateSyncedAsync <T>(this IAggregateHandler handler, CommandContext context, Action <T> updater) where T : class, IDomainObject { return(handler.UpdateSyncedAsync(context, updater.ToAsync())); }