예제 #1
0
        public async Task <IActionResult> Create()
        {
            var nationalParkDtos = await _npRepo.GetAllSync(_npUrl, HttpContext.Session.GetString("JWToken"));

            ViewBag.NationalParksSelectList = new SelectList(nationalParkDtos, "Id", "Name");

            return(View());
        }
        /*
         * public IActionResult Index()
         * {
         *  return View();
         * }
         */

        // 11. Part 2
        // ----------------------------

        public async Task <IActionResult> Index()
        {
            var asd = HttpContext.Session.GetString("JWToken");

            IndexVM indexVM = new IndexVM()
            {
                NationalParkList = await _npRepo.GetAllSync(_npUrl, HttpContext.Session.GetString("JWToken")),
                TrailList        = await _trailRepo.GetAllSync(_trailUrl, HttpContext.Session.GetString("JWToken"))
            };

            return(View(indexVM));
        }
        /* Note About Index()
         * // In the tutorial he make Index action method return empty object. And make other async method that return the nationalParks object.
         * // And that new method will be called by jQuery from the view when configure dataTables plugin. so he make that thing because he want to call the data from the datatable plugin.
         * // As there is no reason for me to this, i worked in the normal way.
         */

        // 9. Part 1
        // ----------------
        public async Task <IActionResult> Index()
        {
            var nationalParkDtos = await _npRepo.GetAllSync(_npUrl, HttpContext.Session.GetString("JWToken"));

            return(View(nationalParkDtos));
        }