Пример #1
0
        public ActionResult <IEnumerable <PetDTO> > GetPets(string GetPets = "GetPets")
        {
            // Log Api call.  Could be moved to database for future anayltics.
            _log.WriteInformation("Controller:Pets,API:GetPets,DateTime:" + DateTime.Now.ToString());

            // Obtain list of pets.
            var pets = _familyDemoAPIv2Repository.GetPets().Result;

            // Map list of pets to DTO.
            var petsList = _mapper.Map <IEnumerable <PetDTO> >(pets);

            // Add name to JSON array.
            var petsListCollection = new
            {
                value = petsList
            };

            // Return pets collection.
            return(Ok(petsListCollection));
        }