public async Task <IActionResult> Index() { var viewModel = new HomeViewModel() { NationalParks = await _nationalParkRepository.GetAll(AppConstants.NationalParkApiPath), Trails = await _trailRepository.GetAll(AppConstants.TrailsApiPath) }; return(View(viewModel)); }
public IActionResult GetNationalParks() { var nationalParks = _nationalParkRepository.GetAll(); var nationalParksDTO = new List <NationalParkDTO>(); foreach (var nationalPark in nationalParks) { nationalParksDTO.Add(_mapper.Map <NationalParkDTO>(nationalPark)); } return(Ok(nationalParksDTO)); }
public async Task <IActionResult> Upsert(int?id) { var nationalParks = await _nationalParkRepository.GetAll(AppConstants.NationalParkApiPath); var viewModel = new TrailViewModel() { NationalParks = nationalParks.Select(p => new SelectListItem() { Text = p.Name, Value = p.Id.ToString() }), Trail = new Trail() }; if (!id.HasValue) { return(View(viewModel)); } viewModel.Trail = await _trailRepository.GetById(AppConstants.TrailsApiPath, id.Value); return(View(viewModel)); }
public async Task <IActionResult> GetAllNationalPark() { return(Json(new { data = await _nationalParkRepository.GetAll(AppConstants.NationalParkApiPath) })); }