Esempio n. 1
0
        public void GetShopperHistory_Returns_ShopperHistory()
        {
            var wxConfig = new WxConfig()
            {
                Token            = "c8e0d9d2-7d0d-4aa4-8cf1-a48c40384988",
                WolliesXEndPoint = "http://dev-wooliesx-recruitment.azurewebsites.net/api/"
            };

            var service = new WooliesXService(wxConfig);

            var result = service.GetShopperHistory();

            Assert.NotNull(result);
        }
Esempio n. 2
0
        private List <Product> GetPopularProducts()
        {
            List <CustomerShopperHistory> result = service.GetShopperHistory();

            var sortedResult = new List <Product>();

            foreach (var history in result)
            {
                foreach (var product in history.products)
                {
                    if (!sortedResult.Select(t => t.name).Contains(product.name))
                    {
                        sortedResult.Add(product);
                    }
                    else
                    {
                        // extract and append quantity
                        sortedResult.Where(t => t.name == product.name).First().quantity += product.quantity;
                    }
                }
            }

            return(sortedResult.OrderByDescending(t => t.quantity).ToList());
        }