예제 #1
0
        public async Task <IActionResult> Upsert(int?id)
        {
            IEnumerable <CampingPark> cpList = await _cpRepo.GetAllAsync(StaticDetails.CampingParkAPIPath, HttpContext.Session.GetString("JWToken"));

            TrailsVM objVM = new TrailsVM()
            {
                CampingParkList = cpList.Select(i => new SelectListItem
                {
                    Text  = i.Name,
                    Value = i.Id.ToString()
                }),
                Trail = new Trail()
            };


            if (id == null)
            {
                // this will be true for insert/create
                return(View(objVM));
            }

            // this will come here for update.
            objVM.Trail = await _tRepo.GetAsync(StaticDetails.TrailAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (objVM.Trail == null)
            {
                return(NotFound());
            }

            return(View(objVM));
        }
예제 #2
0
        public async Task <IActionResult> Index()
        {
            IndexVM listOfCampingParksAndTrails = new IndexVM()
            {
                CampingParkList = await _cpReo.GetAllAsync(StaticDetails.CampingParkAPIPath, HttpContext.Session.GetString("JWToken")),
                TrailList       = await _tRepo.GetAllAsync(StaticDetails.TrailAPIPath, HttpContext.Session.GetString("JWToken"))
            };

            return(View(listOfCampingParksAndTrails));
        }
 public async Task <IActionResult> GetAllCampingPark()
 {
     return(Json(new { data = await _cpRepo.GetAllAsync(StaticDetails.CampingParkAPIPath, HttpContext.Session.GetString("JWToken")) }));
 }