Ejemplo n.º 1
0
        private static void AddItemToEmail(Dictionary <string, List <ProductEmailDetails> > emailsToSend, ProductCatalogEntity product)
        {
            var                 itemDetail   = AmazonProductHelper.GetItemDetails(product.ASIN, product.Country);
            string              itemName     = itemDetail.Items.FirstOrDefault().Item.FirstOrDefault().ItemAttributes.Title;
            var                 cartDetail   = AmazonProductHelper.GetCartDetails(product.ASIN, product.Country);
            string              cartUrl      = cartDetail.Cart.FirstOrDefault().PurchaseURL;
            const string        htmlATag     = @"<a href={0}>Click here to buy!</a>";
            ProductEmailDetails emailDetails = new ProductEmailDetails
            {
                ProductName         = itemName,
                CurrentPrice        = product.CurrentPrice,
                InitialPrice        = product.InitialPrice,
                ProductPurchaseLink = string.Format(htmlATag, cartUrl)
            };

            if (!emailsToSend.ContainsKey(product.EmailId))
            {
                emailsToSend.Add(product.EmailId, new List <ProductEmailDetails> {
                    emailDetails
                });
            }
            else
            {
                emailsToSend[product.EmailId].Add(emailDetails);
            }
        }
Ejemplo n.º 2
0
        public GetProductAPIContract GetProductDetails(GetProductAPIArgs args, HttpRequestMessage request)
        {
            DynamoDBTracer.Tracer.Write(string.Format("GetProductDetails called. Args: {0}", args), "Verbose");
            this.CheckAndUpdateDoSLimits(request, "GetProductCall");
            ItemLookupResponse itemResponse = AmazonProductHelper.GetItemDetails(args.ProductASIN, args.ProductRegion.ToString());

            var item = itemResponse.Items.FirstOrDefault().Item.FirstOrDefault();

            GetProductAPIContract apiContract = new GetProductAPIContract
            {
                ProductASIN   = item.ASIN,
                ProductName   = item.ItemAttributes.Title,
                ProductRegion = args.ProductRegion
            };

            DynamoDBTracer.Tracer.Write(string.Format("GetProductDetails succeeded. Args: {0}", args), "Verbose");
            return(apiContract);
        }