Пример #1
0
        public List <StarshipEntity> GetStarshipEntities()
        {
            string nextResource = apiResource;

            List <StarshipDTO> starshipDtoCollection = new List <StarshipDTO>();

            while (!string.IsNullOrEmpty(nextResource))
            {
                var jsonResponse = _apiContext.Get(nextResource);

                var baseApiResponse = JsonConvert.DeserializeObject <BaseApiResponse <StarshipDTO> >(jsonResponse);

                starshipDtoCollection.AddRange(baseApiResponse.Results);
                nextResource = baseApiResponse.Next;
            }

            var starshipEntities = _mapper.Map <List <StarshipDTO>, List <StarshipEntity> >(starshipDtoCollection);

            return(starshipEntities);
        }