예제 #1
0
        public virtual async Task <IEnumerable <ComposerTemplate> > Process(CommerceContext commerceContext, string[] templateIds)
        {
            GetComposerTemplatesCommand getComposerTemplatesCommand = this;

            IEnumerable <ComposerTemplate> composerTemplates            = Enumerable.Empty <ComposerTemplate>();
            GetComposerTemplatesArgument   getComposerTemplatesArgument = new GetComposerTemplatesArgument(templateIds);

            using (CommandActivity.Start(commerceContext, getComposerTemplatesCommand))
            {
                await getComposerTemplatesCommand.PerformTransaction(commerceContext, async() =>
                {
                    CommercePipelineExecutionContextOptions pipelineContextOptions = commerceContext.PipelineContextOptions;
                    composerTemplates = await this._getComposerTemplatesPipeline.Run(getComposerTemplatesArgument, pipelineContextOptions).ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(composerTemplates);
            }
        }
예제 #2
0
        public override async Task <IEnumerable <ComposerTemplate> > Run(GetComposerTemplatesArgument arg, CommercePipelineExecutionContext context)
        {
            GetComposerTemplatesBlock getComposerTemplatesBlock = this;

            Condition.Requires(arg).IsNotNull(getComposerTemplatesBlock.Name + ": The entity view cannot be null.");

            IEnumerable <ComposerTemplate> composerTemplates = Enumerable.Empty <ComposerTemplate>();

            if (arg.TemplateIds == null || arg.TemplateIds.Length <= 0)
            {
                return(composerTemplates);
            }

            composerTemplates = (await getComposerTemplatesBlock._findEntitiesInListPipeline.Run(new FindEntitiesInListArgument(typeof(ComposerTemplate), CommerceEntity.ListName <ComposerTemplate>() ?? "", 0, int.MaxValue), context).ConfigureAwait(false))
                                ?.List
                                ?.Items
                                .Cast <ComposerTemplate>()
                                .Where(x => arg.TemplateIds.Contains(x.Id))
                                .ToList();

            return(composerTemplates);
        }