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 //}; }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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" })); } }
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)); // --------------------------- }
public IActionResult GetTrailsInNationalPark(int id) { var listObj = _repo.GetTrailsInNationalPark(id); return(Ok(listObj)); }