public virtual async Task CreateTemplateFromProxy(CommerceContext commerceContext, ProxyComposer.ComposerTemplate proxyComposerTemplate)
        {
            ComposerCommander composerCommander = this;

            Condition.Requires(commerceContext).IsNotNull("CommerceContext");
            Condition.Requires(proxyComposerTemplate).IsNotNull("composerTemplate");
            using (CommandActivity.Start(commerceContext, composerCommander))
            {
                KnownResultCodes errorCodes           = commerceContext.GetPolicy <KnownResultCodes>();
                string           composerTemplateName = proxyComposerTemplate.Name;
                if (string.IsNullOrEmpty(composerTemplateName))
                {
                    string composerTemplatePropertyName = "Name";
                    string str2 = await commerceContext.AddMessage(errorCodes.ValidationError, "InvalidOrMissingPropertyValue", new object[1]
                    {
                        composerTemplatePropertyName
                    }, "Invalid or missing value for property '" + composerTemplatePropertyName + "'.").ConfigureAwait(false);

                    return;
                }
                string templateId = proxyComposerTemplate.Id;
                if (await composerCommander.GetEntity <ComposerTemplate>(commerceContext, templateId, false).ConfigureAwait(false) != null)
                {
                    string str = await commerceContext.AddMessage(errorCodes.ValidationError, "NameAlreadyInUse", new object[1]
                    {
                        proxyComposerTemplate.Name
                    }, "Name '" + proxyComposerTemplate.Name + "' is already in use.").ConfigureAwait(false);

                    return;
                }

                ComposerTemplate engineComposerTemplate = new ComposerTemplate(templateId);
                engineComposerTemplate.Name           = proxyComposerTemplate.Name;
                engineComposerTemplate.DisplayName    = proxyComposerTemplate.DisplayName;
                engineComposerTemplate.FriendlyId     = proxyComposerTemplate.Name;
                engineComposerTemplate.LinkedEntities = proxyComposerTemplate.LinkedEntities;

                this.AddTagsFromProxy(engineComposerTemplate, proxyComposerTemplate);
                this.AddComposerTemplateListMembershipsFromProxy(engineComposerTemplate, proxyComposerTemplate);
                await this.AddComposerTemplateEntityViewFromProxy(commerceContext, engineComposerTemplate, proxyComposerTemplate);

                this.AddItemDefinitionsFromProxy(engineComposerTemplate, proxyComposerTemplate);

                int num = await composerCommander.PersistEntity(commerceContext, engineComposerTemplate).ConfigureAwait(false) ? 1 : 0;

                errorCodes = null;
                templateId = null;
            }
        }
Beispiel #2
0
 public DoActionSelectTemplatesToPullFromEnvironmentBlock(ComposerCommander commander, IGetProxyComposerTemplatesPipeline getProxyComposerTemplatesPipeline)
     : base(null)
 {
     this._commander = commander;
     this._getProxyComposerTemplatesPipeline = getProxyComposerTemplatesPipeline;
 }