Example #1
0
        public async Task <IActionResult> Index(string id)
        {
            var model = new RootRedSkyResults();

            var ApiResults = await _redSkyService.ReturnAllApiData();

            var MongoResultById = await _redSkyRepository.GetProductById(id);

            model.DBList = await _redSkyRepository.GetAllProductsFromDatabase();


            JObject Mongo = JObject.Parse(JsonConvert.SerializeObject(MongoResultById.Product));
            JObject Api   = JObject.Parse(JsonConvert.SerializeObject(ApiResults.Product));

            if (id == ApiResults.Product.item.product_Id)
            {
                Mongo.Merge(Api, new JsonMergeSettings
                {
                    // union array values together to avoid duplicates
                    MergeArrayHandling = MergeArrayHandling.Union
                });

                model.Json = Mongo;

                return(View(model));
            }
            else
            {
                model.Json = Mongo;
                return(View(model));
            }
        }
Example #2
0
        public async Task <IActionResult> Hello()
        {
            var model = new RootRedSkyResults();

            model.DBList = await _redSkyRepository.GetAllProductsFromDatabase();

            return(View(model));
        }
Example #3
0
        public async Task <RootRedSkyResults> ReturnAllApiData()
        {
            var url = new Uri($"http://redsky.target.com/v2/pdp/tcin/13860428?excludes=taxonomy,price,promotion,bulk_ship,rating_and_review_reviews,rating_and_review_statistics,question_answer_statistics");

            var response = await client.GetAsync(url);

            object result;

            //var content = response.Content;
            using (var content = response.Content)
            {
                result = await content.ReadAsAsync <object>();
            };

            //product details = JsonConvert.DeserializeObject<product>(result);
            RootRedSkyResults obj = JsonConvert.DeserializeObject <RootRedSkyResults>(result.ToString());

            return(obj);
        }