Example #1
0
        public async Task <IActionResult> Item([FromRoute] int id)
        {
            var item = await _service.GetHackerNewsItemDetails(id);

            var hackerNewsDTO = _mapper.Map <HackerNewsDemoDTO>(item);

            if (item.Kids != null)
            {
                var itemChildren = await _service.GetHackerNewsItemDetails(item.Kids);

                hackerNewsDTO.Kids = _mapper.Map <List <HackerNewsDemoDTO> >(itemChildren);;
            }

            if (item.Parts != null)
            {
                var itemParts = await _service.GetHackerNewsItemDetailsV2(item.Parts);

                hackerNewsDTO.Kids = _mapper.Map <List <HackerNewsDemoDTO> >(itemParts);;
            }

            return(Ok(hackerNewsDTO));
        }
        public async Task GetHackerNewsItem()
        {
            try
            {
                var maxItem = await _service.GetHackerNewsMaxItem();

                if (maxItem > 0)
                {
                    var item = await _service.GetHackerNewsItemDetails(maxItem);

                    Assert.IsTrue(item.Id > 0, "Max Item Retrievable");
                }
                else
                {
                    Assert.Fail("Invalid Max Item");
                }
            }
            catch (AssertFailedException ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Example #3
0
        public async Task <IActionResult> Item([FromRoute] int id)
        {
            var response = await _service.GetHackerNewsItemDetails(id);

            return(Ok(response));
        }