Exemplo n.º 1
0
            private static async Task <IDictionary <long, MediaLocation> > GetMediaLocationDictionary(EcommerceContext ecommerceContext, IEnumerable <long> productIds, IEnumerable <ProductCatalog> catalogs)
            {
                long channelId = await Utilities.GetChannelId(ecommerceContext);

                var             distinctProductIds = productIds.Distinct();
                ManagerFactory  managerFactory     = Utilities.GetManagerFactory(ecommerceContext);
                IProductManager productManager     = managerFactory.GetManager <IProductManager>();

                IDictionary <long, MediaLocation> mediaLocationDictionary = new Dictionary <long, MediaLocation>();
                QueryResultSettings queryResultSettings = new QueryResultSettings()
                {
                    Paging = new PagingInfo()
                    {
                        Skip = 0, Top = 1
                    }
                };

                ProductCatalog firstCatalog = catalogs.FirstOrDefault();
                long           catalogId    = (firstCatalog == null) ? 0 : firstCatalog.RecordId;

                foreach (var productId in distinctProductIds)
                {
                    PagedResult <MediaLocation> mediaLocations = await productManager.GetMediaLocations(productId, channelId, catalogId, queryResultSettings : queryResultSettings);

                    if (mediaLocations.Any())
                    {
                        mediaLocationDictionary.Add(productId, mediaLocations.First());
                    }
                }

                return(mediaLocationDictionary);
            }
Exemplo n.º 2
0
            public static async Task <PagedResult <SalesOrder> > GetAugmentedSalesOrders(EcommerceContext ecommerceContext, PagedResult <SalesOrder> salesOrders)
            {
                if (ecommerceContext == null)
                {
                    throw new ArgumentNullException(nameof(ecommerceContext));
                }

                if (salesOrders.Any())
                {
                    string currencyStringTemplate = await Utilities.GetChannelCurrencyStringTemplate(ecommerceContext);

                    foreach (SalesOrder salesOrder in salesOrders.Results)
                    {
                        salesOrder.ExtensionProperties.SetPropertyValue("CurrencyStringTemplate", ExtensionPropertyTypes.String, currencyStringTemplate);
                    }
                }

                return(salesOrders);
            }