[Authorize]                   //Will only allow authorized users to access this API call
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var obj = _npRepo.GetNationalPark(nationalParkId);

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

            /*
             *   1) Convert output to - NationalParkDto
             *   2) Source Object - obj
             */
            var objDto = _mapper.Map <NationalParkDto>(obj);

            //This is how we would have to map the classes if we didn't have AutoMapper
            //var objDto = new NationalParkDto()
            //{
            //    Created = obj.Created,
            //    Id = obj.Id,
            //    Name = obj.Name,
            //    State = obj.State
            //}

            //This returns Status Code: 200 meaning OK
            return(Ok(objDto));
        }
Exemple #2
0
        public IActionResult GetNationalPark()
        {
            var objList = _npRepo.GetNationalPark();

            var mapeo = _mapper.Map <List <NationalParkDTO> >(objList);

            return(Ok(mapeo));
        }
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var park = _npRepo.GetNationalPark(nationalParkId);

            if (park == null)
            {
                return(NotFound());
            }
            return(Ok(_mapper.Map <NationalPark, NationalParkDto>(park)));
        }
        public IActionResult GetNationalPark(int id)
        {
            var park = _mapper.Map <NationalParkDto>(_npRepository.GetNationalPark(id));

            if (park == null)
            {
                return(NotFound());
            }
            return(Ok(park));
        }
Exemple #5
0
        public IActionResult GetNationalPark(int id)
        {
            var park = _npRepo.GetNationalPark(id);

            if (park is null)
            {
                return(NotFound("Not found message"));
            }
            return(Ok(_mapper.Map <NationalParkDto>(park)));
        }
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var obj = _nationalParkRepository.GetNationalPark(nationalParkId);

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

            return(Ok(_mapper.Map <NationalParkDto>(obj)));
        }
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var nationalPark = _nationalParkRepo.GetNationalPark(nationalParkId);
            var objDto       = _mapper.Map <NationalParkDTO>(nationalPark);

            if (objDto == null)
            {
                return(NotFound());
            }
            return(Ok(objDto));
        }
        public IActionResult GetNationalParks()
        {
            var objList = _nationalParkRepository.GetNationalPark();
            var objDto  = new List <NationalParkDto>();

            foreach (var obj in objList)
            {
                objDto.Add(_mapper.Map <NationalParkDto>(obj));
            }
            return(Ok(objDto));
        }
Exemple #9
0
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var obj = _npRepo.GetNationalPark(nationalParkId);
            if (obj == null)
            {
                return NotFound();
            }
            var objDto = _mapper.Map<NationalParkDto>(obj);

            return Ok(objDto);
        }
Exemple #10
0
        public IActionResult GetNationalPark(int id)
        {
            var obj = _npRepo.GetNationalPark(id);

            if (obj == null)
            {
                return(NotFound(new { message = "Invalid id" }));
            }
            var objDto = _mapper.Map <NationalParkDto>(obj);

            return(Ok(objDto));
        }
Exemple #11
0
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var nationalParkobj = _nationalParkRepository.GetNationalPark(nationalParkId);

            if (nationalParkobj == null)
            {
                return(NotFound());
            }
            var nationalParkObjDto = _mapper.Map <NationalParkDto>(nationalParkobj);

            return(Ok(nationalParkObjDto));
        }
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var park = _npRepository.GetNationalPark(nationalParkId);

            if (park == null)
            {
                return(NotFound());
            }
            var mappedPark = _mapper.Map <NationalParkDto>(park);

            return(Ok(mappedPark));
        }
        public IActionResult GetNationalPark(int nationalParkId)
        {
            NationalPark nationalPark = _npRepo.GetNationalPark(nationalParkId);

            if (nationalPark == null)
            {
                return(NotFound());
            }
            NationalParkDto nationalParkDto = _mapper.Map <NationalParkDto>(nationalPark);

            return(Ok(nationalParkDto));
        }
        public IActionResult GetNationalPark(int NationalParkId)
        {
            var obj = _npRepo.GetNationalPark(NationalParkId);

            if (obj == null)
            {
                return(NotFound());
            }
            var objDTO = _mapper.Map <NationalParkDto>(obj);

            return(Ok(objDTO));
        }
        public IActionResult GetNationalPark(int id)
        {
            var park = _npRepo.GetNationalPark(id);

            if (park == null)
            {
                return(NotFound());
            }
            var parkDto = _mapper.Map <NationalParkDto>(park);

            return(Ok(parkDto));
        }
        public async Task <IActionResult> GetNationalPark(int id)
        {
            var park = await _repo.GetNationalPark(id);

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

            var parkToDto = _mapper.Map <NationalParkDto>(park);

            return(Ok(parkToDto));
        }
Exemple #17
0
 public ActionResult GetNationalParkById(int id)
 {
     if (_npRepo.NationalParkExists(id))
     {
         var park    = _npRepo.GetNationalPark(id);
         var parkDto = _mapper.Map <NationalParkDto>(park);
         return(Ok(parkDto));
     }
     else
     {
         return(NotFound());
     }
 }
        public IActionResult GetNationalPark(int id)
        {
            var nationalPark = nationalParkRepository.GetNationalPark(id);

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

            var natParkDto = mapper.Map <NationalParkDto>(nationalPark);

            return(Ok(natParkDto));
        }
Exemple #19
0
        public IActionResult GetLocation(int locationId)
        {
            var obj = _npRepo.GetNationalPark(locationId);

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

            var objDto = _mapper.Map <LocationDto>(obj);

            return(Ok(objDto));
        }
        public IActionResult GetNationalPark(int nationalparkId)
        {
            var Obj = npRepository.GetNationalPark(nationalparkId);

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

            var ObjDTO = mapper.Map <NationalParkDTO>(Obj);

            return(Ok(ObjDTO));
        }
        public IActionResult GetNationalPark(int id)
        {
            var obj = _repo.GetNationalPark(id);

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

            var objDto = _mapper.Map <NationalParkDto>(obj);

            return(Ok(objDto));
        }
        public IActionResult GetNationalPark(int id)
        {
            var nationalPark = _npRepository.GetNationalPark(id);

            if (nationalPark != null)
            {
                return(Ok(_mapper.Map <NationalParkDTO>(nationalPark)));
            }
            else
            {
                return(NotFound(new { message = "There is no data for this id!" }));
            }
        }
Exemple #23
0
        [Authorize]                                                 // 12. Part 2
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var nationalPark = npRepository.GetNationalPark(nationalParkId);

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

            // Convert NationalPark object (Domain Model) to NationalParkDto (Dto)
            var npDto = mapper.Map <NationalParkDto>(nationalPark);

            return(Ok(npDto));
        }
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var domainObject = _repository.GetNationalPark(nationalParkId);

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

            var dtoItem = _mapper.Map <NationalParkDto>(domainObject);


            return(Ok(dtoItem));
        }
Exemple #25
0
        public async Task <IActionResult> GetNationalPark(int id)
        {
            var obj = await _repo.GetNationalPark(id);

            if (obj == null)
            {
                return(NotFound());
            }
            else
            {
                var objDTO = _mapper.Map <NationalParkDTO>(obj);
                return(Ok(objDTO));
            }
        }
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var objFromDb = _npRepo.GetNationalPark(nationalParkId);

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


            var returnObj = _newParky.Map <NationalParkDto>(objFromDb);

            return(Ok(returnObj));
        }
Exemple #27
0
        public IActionResult GetNationalParks()
        {
            var objList = _npRepo.GetNationalPark();

            //This will ensure we send our Dto instead of the model
            var objDto = new List <NationalParkDto>();

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

            return(Ok(objDto));
        }
        public ActionResult GetNationalPark(int nationalParkId)
        {
            var objPark = _nrepo.GetNationalPark(nationalParkId);
            var objDto  = _mapper.Map <NationalParkDto>(objPark);

            return(Ok(objDto));
        }
        public IActionResult GetNationalPark()
        {
            var obj = _npRepo.GetNationalPark().FirstOrDefault();

            var mapeo = _mapper.Map <NationalParkDTO>(obj);

            return(Ok(mapeo));
        }
        public IActionResult GetNationalPark(int nationalParkId)
        {
            var obj = _npRepo.GetNationalPark(nationalParkId);

            if (obj == null)
            {
                return(NotFound());
            }
            var objDto = _mapper.Map <NationalParkDto>(obj);

            // var objDto = new NationalParkDto()
            // {
            //     Created = obj.Created,
            //     Id = obj.Id,
            //     Name = obj.Name,
            //     State = obj.State,
            // };
            return(Ok(objDto));
        }