Ejemplo n.º 1
0
        protected Task On(CreateRule command, CommandContext context)
        {
            return(handler.CreateSyncedAsync <RuleDomainObject>(context, async r =>
            {
                await GuardRule.CanCreate(command, appProvider);

                r.Create(command);
            }));
        }
Ejemplo n.º 2
0
        protected Task On(CreateSchema command, CommandContext context)
        {
            return(handler.CreateSyncedAsync <SchemaDomainObject>(context, async s =>
            {
                await GuardSchema.CanCreate(command, appProvider);

                s.Create(command);

                context.Complete(EntityCreatedResult.Create(command.SchemaId, s.Version));
            }));
        }
Ejemplo n.º 3
0
        protected async Task On(CreateApp command, CommandContext context)
        {
            var app = await handler.CreateSyncedAsync <AppDomainObject>(context, async a =>
            {
                await GuardApp.CanCreate(command, appProvider);

                a.Create(command);

                context.Complete(EntityCreatedResult.Create(command.AppId, a.Version));
            });
        }
Ejemplo n.º 4
0
        protected async Task On(CreateAsset command, CommandContext context)
        {
            command.ImageInfo = await assetThumbnailGenerator.GetImageInfoAsync(command.File.OpenRead());

            try
            {
                var asset = await handler.CreateSyncedAsync <AssetDomainObject>(context, async a =>
                {
                    GuardAsset.CanCreate(command);

                    a.Create(command);

                    await assetStore.UploadTemporaryAsync(context.ContextId.ToString(), command.File.OpenRead());

                    context.Complete(EntityCreatedResult.Create(command.AssetId, a.Version));
                });

                await assetStore.CopyTemporaryAsync(context.ContextId.ToString(), command.AssetId.ToString(), asset.Snapshot.FileVersion, null);
            }
            finally
            {
                await assetStore.DeleteTemporaryAsync(context.ContextId.ToString());
            }
        }
Ejemplo n.º 5
0
 public static Task <T> CreateSyncedAsync <T>(this IAggregateHandler handler, CommandContext context, Action <T> creator) where T : class, IDomainObject
 {
     return(handler.CreateSyncedAsync(context, creator.ToAsync()));
 }