Пример #1
0
        public ActionResult Product(string id, int page = 1)
        {
            List<AmazonItem> list = new List<AmazonItem>();
            List<AmazonItem> listu = new List<AmazonItem>();
            AmazonServices Amazonhelper = new AmazonServices();

            while (listu.Count < 9 && page < 11 && id != "Search")
            {
                //string cat = new Helpers().CatgoryByKeyword(id).CategoryName;

                list = Amazonhelper.ItemSearch( page.ToString(),id.Replace(" ","_"), null);

                for (int i = list.Count - 1; i >= 0; i--)
                {
                    if (listu.Where(x => x.ProductId == list[i].ProductId).Count() == 0)
                    {
                        listu.Add(list[i]);
                    }
                }
                page++;
            }

            return View("Products",listu);
        }
Пример #2
0
        public ActionResult Category(string id, int page = 1)
        {
            List<AmazonItem> list = new List<AmazonItem>();
            List<AmazonItem> listu = new List<AmazonItem>();
            AmazonServices Amazonhelper = new AmazonServices();

            while (listu.Count < 9 && page < 11 && id != "Search")
            {
                //string kw = new Helpers().RandomKeywordByCategory(id).KeywordName;

                list = Amazonhelper.ItemSearch(page.ToString(),null, id);

                for (int i = list.Count - 1; i >= 0; i--)
                {
                    if (listu.Where(x => x.ProductId == list[i].ProductId).Count() == 0)
                    {
                        listu.Add(list[i]);
                    }
                }
                    page++;
            }

            return View(listu);
        }
Пример #3
0
        public ActionResult Index()
        {
            var kw = kwRepository.GetAll().ToList();
            ViewBag.keywords = string.Join(",",kw);

            int pagenum = 1;
            List<AmazonItem> list = new List<AmazonItem>();
            List<AmazonItem> list2 = new List<AmazonItem>();
            List<AmazonItem> listu = new List<AmazonItem>();

            int total = kwRepository.GetAll().Count();

            AmazonServices Amazonhelper = new AmazonServices();

            //Amazon only allows 10 pages
            while (listu.Count < 16 && pagenum < 11)
            {
                Helpers helper = new Helpers();

                var a = helper.RandomKeyword(total);
                var b = helper.RandomKeyword(total);

               // string catA = catRepository.GetById(a.CategoryId).CategoryName;
               // string catB = catRepository.GetById(b.CategoryId).CategoryName;

                list = Amazonhelper.ItemSearch( pagenum.ToString(),a.KeywordName, null);

                list2 = Amazonhelper.ItemSearch(pagenum.ToString(),b.KeywordName, null);

                foreach (var prod in list2)
                {
                    for (int i = list.Count - 1; i >= 0; i--)
                    {
                        if (list[i].Equals(prod))
                            list.Remove(prod);
                    }
                }

                listu.AddRange(list.Union(list2));

                pagenum++;
            }

            IndexViewModel model = new IndexViewModel();

               model.amazon = listu;

            return View(model);
        }