Exemple #1
0
        public async Task <IActionResult> Index()
        {
            var viewModel = new HomeViewModel()
            {
                NationalParks = await _nationalParkRepository.GetAll(AppConstants.NationalParkApiPath),
                Trails        = await _trailRepository.GetAll(AppConstants.TrailsApiPath)
            };

            return(View(viewModel));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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) }));
 }