public async Task <bool> Process(CommerceContext commerceContext, IEnumerable <CatalogItemParentAssociationModel> associationList)
        {
            using (CommandActivity.Start(commerceContext, this))
            {
                foreach (var association in associationList)
                {
                    commerceContext.ClearMessages();

                    await PerformTransaction(commerceContext, async() =>
                    {
                        var relationshipType = Command <GetRelationshipTypeCommand>().Process(commerceContext, association.ParentId, association.ItemId);
                        await Command <DeleteRelationshipCommand>().Process(commerceContext, association.ParentId, association.ItemId, relationshipType);
                    });
                }

                return(true);
            }
        }
예제 #2
0
        public async Task <bool> Process(CommerceContext commerceContext, IEnumerable <CatalogItemParentAssociationModel> associationList)
        {
            using (CommandActivity.Start(commerceContext, this))
            {
                // TODO: This is not tested
                // TODO: draw insperation from Sitecore.Commerce.Plugin.Catalog.DoActionDisassociateBlock
                foreach (var association in associationList)
                {
                    // Need to clear message as any prior error will cause all transactions to abort.
                    commerceContext.ClearMessages();

                    await PerformTransaction(commerceContext, async() =>
                    {
                        var relationshipType = Command <GetRelationshipTypeCommand>().Process(commerceContext, association.ParentId, association.ItemId);
                        await Command <DeleteRelationshipCommand>().Process(commerceContext, association.ParentId, association.ItemId, relationshipType);
                    });
                }

                return(true);
            }
        }
예제 #3
0
        public async Task <bool> Process(CommerceContext commerceContext, IEnumerable <CommerceEntity> items)
        {
            using (CommandActivity.Start(commerceContext, this))
            {
                commerceContext.Logger.LogInformation($"Called - {nameof(PersistEntityBulkCommand)}.");

                foreach (var item in items)
                {
                    commerceContext.ClearMessages();

                    await PerformTransaction(commerceContext, async() =>
                    {
                        var arg = new PersistEntityArgument(item);
                        await Pipeline <IPersistEntityPipeline>().Run(arg, commerceContext.PipelineContextOptions);
                    });
                }

                commerceContext.Logger.LogInformation($"Completed - {nameof(PersistEntityBulkCommand)}.");

                return(true);
            }
        }
예제 #4
0
        public async Task <bool> Process(CommerceContext commerceContext, IEnumerable <ParentAssociationModel> associationList)
        {
            using (CommandActivity.Start(commerceContext, this))
            {
                commerceContext.Logger.LogInformation($"Called - {nameof(AssociateToParentBulkCommand)}.");

                foreach (var association in associationList)
                {
                    // Need to clear message as any prior error will cause all transactions to abort.
                    commerceContext.ClearMessages();

                    await PerformTransaction(commerceContext, async() =>
                    {
                        var relationshipType = Command <GetRelationshipTypeCommand>().Process(commerceContext, association.ParentId, association.ItemId);
                        await Command <CreateRelationshipCommand>().Process(commerceContext, association.ParentId, association.ItemId, relationshipType);
                    });
                }

                commerceContext.Logger.LogInformation($"Completed - {nameof(AssociateToParentBulkCommand)}.");

                return(true);
            }
        }