예제 #1
0
        public async Task <IEnumerable <AnimalListing> > Get(AnimalsService.Store store = AnimalsService.Store.Sample, int start = 0, int limit = 6)
        {
            var animals = await this._animalsService.GetAsync(store, start, limit);

            var animalListings = AnimalListing.fromRescueGroups(animals);

            return(animalListings);
        }
예제 #2
0
        public List <AnimalListing> GetAnimals()
        {
            HttpWebRequest  request  = WebRequest.CreateHttp("https://gc-zoo.surge.sh/api/animals.json");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader    rd       = new StreamReader(response.GetResponseStream());
            string          ApiText  = rd.ReadToEnd();

            JToken tokens = JToken.Parse(ApiText);

            List <JToken> ts = tokens["results"].ToList();

            List <AnimalListing> animals = new List <AnimalListing>();

            foreach (JToken t in ts)
            {
                AnimalListing a = new AnimalListing(t);
                animals.Add(a);
            }

            return(animals);
        }