コード例 #1
0
        public PublishResult Publish()
        {
            if (!_feedsValid)
            {
                return(new PublishResult {
                    Success = false, Error = "Feeds not yet successfully validated"
                });
            }

            var publishManager = new PublishManager(_accessKey, _secretKey, _region);
            var publishResult  = new PublishResult();

            if (!_productsPushed && _productCollection.GetCollectionState().ItemCount != 0)
            {
                publishResult.PublishProductFeedResult = publishManager.PublishProductFeed(_productCollection.GetItems(), _accountPriceCollection.GetItems()).Result;
                _productsPushed = true;
            }

            if (_categoryCollection.GetCollectionState().ItemCount != 0)
            {
                publishResult.PublishCategoryFeedResult = publishManager.PublishCategoryFeed(_categoryCollection.GetItems()).Result;
            }

            if (_brandCollection.GetCollectionState().ItemCount != 0)
            {
                publishResult.PublishBrandFeedResult = publishManager.PublishBrandFeed(_brandCollection.GetItems()).Result;
            }

            if (_userCollection.GetCollectionState().ItemCount != 0)
            {
                publishResult.PublishUserFeedResult = publishManager.PublishUserFeed(_userCollection.GetItems()).Result;
            }

            publishResult.Success = (publishResult.PublishProductFeedResult?.Success ?? true) &&
                                    (publishResult.PublishCategoryFeedResult?.Success ?? true) &&
                                    (publishResult.PublishUserFeedResult?.Success ?? true);

            return(publishResult);
        }