コード例 #1
0
        public IActionResult GetTrailInNationalPark(int nationalParkId)
        {
            var objList = _trailRepo.GetTrailsInNationalPark(nationalParkId);

            if (objList == null)
            {
                return(NotFound());
            }
            var objDto = new List <TrailDto>();

            foreach (var obj in objList)
            {
                objDto.Add(_mapper.Map <TrailDto>(obj));
            }

            return(Ok(objDto));

            //WITH OUT AUTO MAPPER THIS IS THE CODE U'LL WRITE BELOW
            //var objDto = new TrailDto()
            //{
            //	Created = obj.Created,
            //	Id = obj.Id,
            //	Name = obj.Name,
            //	State = obj.State
            //};
        }
コード例 #2
0
        public IActionResult GetTrailsInNationalPark(int nationalParkId)
        {
            var objList = _trailRepo.GetTrailsInNationalPark(nationalParkId);

            if (objList == null)
            {
                return(NotFound());
            }

            var objDto = new List <TrailDto>();

            foreach (var obj in objList)
            {
                objDto.Add(_mapper.Map <TrailDto>(obj));
            }
            //var objDto = new TrailDto()
            //{
            //    Created = obj.Created,
            //    Id = obj.Id,
            //    Name = obj.Name,
            //    State = obj.State
            //};

            return(Ok(objDto));
        }
コード例 #3
0
        public IActionResult GetTrailInNp(int nationalParkId)
        {
            var objList = _trailRepo.GetTrailsInNationalPark(nationalParkId);
            var objDTO  = new List <TrailDTO>();

            foreach (var obj in objList)
            {
                objDTO.Add(_mapper.Map <TrailDTO>(obj));
            }
            return(Ok(objDTO));
        }
コード例 #4
0
        public IActionResult GetTrailsInNationalPark(int nationalParkId)
        {
            var objList = _trailRepo.GetTrailsInNationalPark(nationalParkId);

            if (objList == null || objList.Count() == 0)
            {
                return(NotFound());
            }
            var objDto = _mapper.Map <ICollection <TrailDto> >(objList);

            return(Ok(objDto));
        }
コード例 #5
0
        public IActionResult GetTrailsInNationalPark(int nationalparkid)
        {
            var TrailList    = trailRepository.GetTrailsInNationalPark(nationalparkid);
            var TrailDTOList = new List <TrailDTO>();

            foreach (var obj in TrailList)
            {
                TrailDTOList.Add(mapper.Map <TrailDTO>(obj));
            }

            return(Ok(TrailDTOList));
        }
コード例 #6
0
        public IActionResult GetTrailsInNationalPark(int nationalParkId)
        {
            var trails = _trailRepository.GetTrailsInNationalPark(nationalParkId);

            if (trails == null)
            {
                return(NotFound());
            }
            var mappedTrails = _mapper.Map <ICollection <TrailDto> >(trails);

            return(Ok(mappedTrails));
        }
コード例 #7
0
        public IActionResult GetTrailsInNationalPark(int nationalParkId)
        {
            var trails = _trailRepo.GetTrailsInNationalPark(nationalParkId);

            if (trails == null)
            {
                return(NotFound());
            }

            var trailsDto = trails
                            .Select(trail => _mapper.Map <TrailDto>(trail))
                            .ToList();

            return(Ok(trailsDto));
        }
コード例 #8
0
        public IActionResult GetTrailInNationalPark(int nationalParkId)
        {
            var objList = _trailRepo.GetTrailsInNationalPark(nationalParkId);

            if (objList == null)
            {
                return(NotFound());
            }
            var objDto = new List <TrailDto>();

            foreach (var obj in objList)
            {
                objDto.Add(_mapper.Map <TrailDto>(obj));
            }
            return(Ok(objDto));
        }
コード例 #9
0
        public IActionResult GetTrailsInNationalPark(int nationalParkId)
        {
            var trails = _trailRepository.GetTrailsInNationalPark(nationalParkId);

            if (trails == null)
            {
                return(NotFound());
            }
            var trailDto = new List <TrailDto>();

            foreach (var trail in trails)
            {
                trailDto.Add(_mapper.Map <TrailDto>(trail));
            }
            return(Ok(trailDto));
        }
コード例 #10
0
        public IActionResult GetTrailInNationalPark(int nationalParkId)
        {
            var TrailList = TrailRepository.GetTrailsInNationalPark(nationalParkId);

            if (TrailList == null)
            {
                return(NotFound());
            }
            var objDto = new List <TrailsDto>();

            foreach (var item in TrailList)
            {
                objDto.Add(mapper.Map <TrailsDto>(item));
            }


            return(Ok(objDto));
        }
コード例 #11
0
        public IActionResult GetTrailsInNationalPark(int nationalParkId)
        {
            var trails = _tRepository.GetTrailsInNationalPark(nationalParkId);

            if (trails != null)
            {
                var trailDTOList = new List <TrailDTO>();

                foreach (var trail in trails)
                {
                    trailDTOList.Add(_mapper.Map <TrailDTO>(trail));
                }

                return(Ok(trailDTOList));
            }
            else
            {
                return(NotFound(new { message = "There is no data" }));
            }
        }
コード例 #12
0
        public IActionResult GetTrailsInNationalPark(int npId)
        {
            // 7. Part 6
            // ---------------------------

            var trails = trailRepository.GetTrailsInNationalPark(npId);

            if (trails == null)
            {
                return(NotFound($"National Park with id:{npId}  not exist."));
            }

            var trailsDtos = new List <TrailDto>();

            foreach (var trail in trails)
            {
                var trailDto = mapper.Map <TrailDto>(trail);
                trailsDtos.Add(trailDto);
            }

            return(Ok(trailsDtos));

            // ---------------------------
        }
コード例 #13
0
        public IActionResult GetTrailsInNationalPark(int id)
        {
            var listObj = _repo.GetTrailsInNationalPark(id);

            return(Ok(listObj));
        }