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));
            }
        }
        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));
            }
        }
        public ReviewListMapper(IAmazonRequest amazonRequest, List<ReviewDTO> reviews, List<ProductDTO> products)
        {
            this.amazonRequest = amazonRequest;

            this.reviews = reviews;
            this.products = products;
            errors = new List<KeyValuePair<string, string>>();
        }
Ejemplo n.º 4
0
        public AmazonFactory(IAmazonRequest amazonRequest)
        {
            amazonResponse = new AmazonResponse { Errors = new List<KeyValuePair<string, string>>() };

            amazonResponse.Errors = amazonRequest.Validate();

            if(amazonResponse.Errors.Count == 0)
            {
                if (!string.IsNullOrEmpty(amazonRequest.ListId))
                {
                    productListMapper = new ProductListMapper(amazonRequest);
                }

                if (!string.IsNullOrEmpty(amazonRequest.CustomerId))
                {
                    reviewListMapper = new ReviewListMapper(amazonRequest);
                }                
            }
        }
 public AmazonApplication(IAmazonRequest amazonRequest, IFileParameters fileParameters)
 {
     amazonFactory = new AmazonFactory(amazonRequest);
     this.fileParameters = fileParameters;
 }