public async Task <SubaccountAcctionsResult> Process(CommerceContext commerceContext, List <string> subaccountsId, string mainaccountId)
        {
            var subaccounts = await _getSubaccounts.Process(commerceContext, mainaccountId);

            var validSubaccounts = subaccountsId.Where(x => subaccounts.Subaccounts.Any(y => y.Id == x));

            if (!validSubaccounts.Any())
            {
                return(new SubaccountAcctionsResult {
                    Completed = false
                });
            }

            using (CommandActivity.Start(commerceContext, (CommerceCommand)this))
            {
                foreach (string id in validSubaccounts)
                {
                    await _delete.Run(new GetCustomerArgument(id, string.Empty), commerceContext.GetPipelineContext());
                }
            }

            return(new SubaccountAcctionsResult {
                Completed = true
            });
        }
예제 #2
0
        public async Task <SubaccountAcctionsResult> Process(CommerceContext commerceContext, SubaccountModel subaccount, string mainaccountId)
        {
            Customer result;
            var      subaccounts = await _getSubaccountsCommand.Process(commerceContext, mainaccountId);

            var validSubaccount = subaccounts.Subaccounts.FirstOrDefault(x => x.Id.Equals(subaccount.Id, StringComparison.OrdinalIgnoreCase));

            if (validSubaccount == null)
            {
                return(new SubaccountAcctionsResult {
                    Completed = false
                });
            }
            using (CommandActivity.Start(commerceContext, (CommerceCommand)this))
            {
                result = await _updateSubaccountPipeline.Run(subaccount, commerceContext.GetPipelineContext());

                if (result == null)
                {
                    new SubaccountAcctionsResult {
                        Completed = false
                    };
                }
            }

            return(new SubaccountAcctionsResult {
                Completed = true
            });
        }
예제 #3
0
        /// <summary>
        ///     Retrieves all component types applicable for the sellable item
        /// </summary>
        /// <param name="context"></param>
        /// <param name="sellableItem">Sellable item for which to get the applicable components</param>
        /// <returns></returns>
        public async Task <List <Type> > GetApplicableComponentTypes(CommerceContext context, SellableItem sellableItem)
        {
            // Get the item definition
            var catalogs = sellableItem.GetComponent <CatalogsComponent>();

            // TODO: What happens if a sellableitem is part of multiple catalogs?
            var catalog        = catalogs.GetComponent <CatalogComponent>();
            var itemDefinition = catalog.ItemDefinition;

            var sellableItemComponentsArgument = new SellableItemComponentsArgument();

            sellableItemComponentsArgument = await this.Pipeline <IGetSellableItemComponentsPipeline>().Run(sellableItemComponentsArgument, context.GetPipelineContext());

            var applicableComponentTypes = new List <Type>();

            foreach (var component in sellableItemComponentsArgument.SellableItemComponents)
            {
                System.Attribute[] attrs = System.Attribute.GetCustomAttributes(component);

                if (attrs.Any(attr => attr is AllSellableItemsAttribute))
                {
                    applicableComponentTypes.Add(component);
                }
                else if (attrs.Any(attr => attr is ItemDefinitionAttribute && ((ItemDefinitionAttribute)attr).ItemDefinition == itemDefinition))
                {
                    applicableComponentTypes.Add(component);
                }
            }

            return(applicableComponentTypes);
        }
예제 #4
0
        /// <summary>
        ///     Returns all registered component types
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <List <Type> > GetAllComponentTypes(CommerceContext context)
        {
            var sellableItemComponentsArgument = new SellableItemComponentsArgument();

            sellableItemComponentsArgument = await this.Pipeline <IGetSellableItemComponentsPipeline>().Run(sellableItemComponentsArgument, context.GetPipelineContext());

            return(sellableItemComponentsArgument.SellableItemComponents);
        }