コード例 #1
0
        public ReviewListMapper(IAmazonRequest amazonRequest)
        {
            this.amazonRequest = amazonRequest;
            errors = new List<KeyValuePair<string, string>>();

            try
            {
                var reviewMapper = new ReviewMapper(amazonRequest.AccessKeyId, amazonRequest.AssociateTag, amazonRequest.SecretAccessKey, amazonRequest.CustomerId);

                reviews = reviewMapper.GetReviews();

                foreach (var error in reviewMapper.GetErrors())
                {
                    errors.Add(error);
                }

                var productMapper = new ProductMapper(amazonRequest.AccessKeyId, amazonRequest.AssociateTag, amazonRequest.SecretAccessKey);

                products = productMapper.GetProducts(reviews.ConvertAll(review => review.ASIN));

                foreach (var error in productMapper.GetErrors())
                {
                    errors.Add(error);
                }
            }
            catch(Exception ex)
            {
                errors.Add(new KeyValuePair<string, string>("ServiceError", ex.Message));
            }
        }
コード例 #2
0
        public ProductListMapper(IAmazonRequest amazonRequest)
        {
            this.amazonRequest = amazonRequest;
            errors = new List<KeyValuePair<string, string>>();

            try
            {
                var listMapper = new ListMapper(amazonRequest.AccessKeyId, amazonRequest.AssociateTag, amazonRequest.SecretAccessKey, amazonRequest.ListId);

                listItems = listMapper.GetList();

                foreach (var error in listMapper.GetErrors())
                {
                    errors.Add(error);
                }

                var productMapper = new ProductMapper(amazonRequest.AccessKeyId, amazonRequest.AssociateTag, amazonRequest.SecretAccessKey);

                products = productMapper.GetProducts(listItems.ConvertAll(listItem => listItem.ASIN));

                foreach (var error in productMapper.GetErrors())
                {
                    errors.Add(error);
                }
            }
            catch(Exception ex)
            {
                errors.Add(new KeyValuePair<string, string>("ServiceError", ex.Message));
            }
        }