public async Task <IActionResult> Upsert(int?id) { // create object list nationalpark IEnumerable <NationalPark> npList = await _nationalParkRepository.GetAllAsync(SD.NationalParkAPIPath, HttpContext.Session.GetString("JWToken")); TrailVM objVM = new TrailVM() { NationalParkList = npList.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }), Trail = new Trail() // add object reference to acces Id }; if (id == null) { // this will be true for insert/create return(View(objVM)); } objVM.Trail = await _trailRepository.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken")); if (objVM.Trail == null) { return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> npList = await nationalParkRepository.GetAllAsync(SD.NationalParkApiPath); TrailsVM objVM = new TrailsVM() { NationalParkList = npList.Select(x => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem { Value = x.Id.ToString(), Text = x.Name }), Trail = new Trail() }; if (id == null) { return(View(objVM)); } objVM.Trail = await trailRepository.GetAsync(SD.TrailApiPath, id.GetValueOrDefault()); if (objVM.Trail == null) { return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> npList = await _nationalParkRepository.GetAllAsync(SD.NationalParkUrl, HttpContext.Session.GetString("JWToken")); TrailsViewModel viewModel = new TrailsViewModel() { NationalParkList = npList.Select(np => new SelectListItem { Text = np.Name, Value = np.Id.ToString() }) }; if (id == null) { return(View(viewModel)); } viewModel.Trail = await _trailRepository.GetAsync(SD.TrailUrl, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken")); if (viewModel.Trail == null) { return(NotFound()); } return(View(viewModel)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> nationalParks = await _npRepository.GetAllAsync(SD.NationalParkAPIPath, Token); TrailsVM trailsVM = new TrailsVM() { NationalParks = nationalParks.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }), Trail = new Trail() }; if (id == null) { return(View(trailsVM)); } trailsVM.Trail = await _trailRepository.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault(), Token); if (trailsVM.Trail == null) { return(RedirectToAction("AccessDenied", "Home")); } return(View(trailsVM)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> npList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath, HttpContext.Session.GetString("JWTToken")); TrailVM objVM = new TrailVM() { NationalParkList = npList.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }) }; if (id == null) { objVM.Trail = new Trail(); return(View(objVM)); // insert or create } // flow come here for update objVM.Trail = await _trailRepo.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWTToken")); if (objVM == null) { return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> Upsert(int?Id) { var nationalParksList = await _nationalPark.GetAllAsync(StaticDetails.NationalParkApiUrl); TrailViewModel trailViewModel = new TrailViewModel() { NationalParks = nationalParksList.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }), Trail = new Trail() }; if (Id == null) { return(View(trailViewModel)); } trailViewModel.Trail = await _trailRepository.GetAsync(StaticDetails.TrailsApiUrl, Id.GetValueOrDefault()); if (trailViewModel.Trail == null) { return(NotFound()); } return(View(trailViewModel)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> npList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath, HttpContext.Session.GetString("JWToken")); TrailsVM objVm = new TrailsVM() { NationalParkList = npList.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }), Trails = new Trails() }; if (id == null) { //this will be for create return(View(objVm)); } //for update objVm.Trails = await _trailRepo.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken")); if (objVm.Trails == null) { return(NotFound()); } return(View(objVm)); }
public async Task <IActionResult> Upsert(int?id) { var token = HttpContext.Session.GetString("JWTToken"); IEnumerable <NationalPark> npList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath); TrailsVM objVM = new TrailsVM() { NationalParkList = npList.Select(x => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem { Text = x.Name, Value = x.Id.ToString() }), Trails = new Trail() }; if (id == null) { return(View(objVM)); } objVM.Trails = await _trailRepo.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault(), token); if (objVM.Trails == null) { return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> nationalParkList = await nationalParkRepository.GetAllAsync(SD.NationalParkAPIUrl, HttpContext.Session.GetString("JWTToken")); TrailVM trailVM = new TrailVM { NationalParkList = nationalParkList.Select(s => new SelectListItem() { Text = s.Name, Value = s.Id.ToString() }), Trail = new Trail() }; NationalPark nationalPark = new NationalPark(); if (id == 0) { return(View(trailVM)); } trailVM.Trail = await trailRepository.GetAsync(SD.TrainAPIUrl, id.GetValueOrDefault(), HttpContext.Session.GetString("JWTToken")); if (trailVM.Trail == null) { return(NotFound()); } return(View(trailVM)); }
public async Task <IActionResult> Upsert(int?id) { var npList = await _npRepo.GetAllAsync(StaticDetails.NationalParksApiPath); var trailVm = new TrailsVm { NationalParkList = npList.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }), Trail = new Trail() }; if (id == null) { // true for Insert/Create return(View(trailVm)); } trailVm.Trail = await _trailRepo.GetAsync(StaticDetails.TrailsApiPath, id.GetValueOrDefault()); if (trailVm.Trail == null) { return(NotFound()); } return(View(trailVm)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> npList = await _nationalParkRepository.GetAllAsync(SD.NationalAPIPath, HttpContext.Session.GetString("JWToken")); TrailsVM trailsVm = new TrailsVM() { NationParkList = npList.Select(i => new SelectListItem() { Text = i.Name, Value = i.Id.ToString() }), Trail = new Trail() }; if (id == null) { return(View(trailsVm)); } trailsVm.Trail = await _trailRepository.GetAsync(SD.TrailsAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken")); if (trailsVm.Trail == null) { return(NotFound()); } return(View(trailsVm)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> npList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath); TrailsViewModel objVM = new TrailsViewModel() { NationalParkList = npList.Select(i => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem { Text = i.Name, Value = i.Id.ToString() }), Trail = new Trail() }; if (id == null) { return(View(objVM)); } objVM.Trail = await _trailRepo.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault()); if (objVM.Trail == null) { return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> Upsert(int?id) { var token = HttpContext.Session.GetString("JwToken"); IEnumerable <NationalPark> nationalParkList = await _npRepository.GetAllAsync(SD.NationalParkAPIPath, token); TrailVM trailVM = new TrailVM() { NationalParkList = nationalParkList.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }), Trail = new Trail() }; if (id == null) { return(View(trailVM)); } else { trailVM.Trail = await _tRepository.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault(), token); if (trailVM.Trail == null) { return(NotFound()); } return(View(trailVM)); } }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> npList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath, HttpContext.Session.GetString("JWToken")); TrailsVM objVM = new TrailsVM() { NationalParkList = npList.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }), Trail = new Trail() }; if (id == null) { //Insert Or create return(View(objVM)); } objVM.Trail = await _npTrail.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken")); if (objVM.Trail == null) { //Edit or Update return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> UpSert(int?id) { IEnumerable <NationalPark> nationalParks = await _nationalParkRepository.GetAllAsync(SD.NationalParkAPIPath, HttpContext.Session.GetString("JWToken")); TrailsVM objVM = new TrailsVM() { NationalParkList = nationalParks.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)); } //Flow will come here for update objVM.Trail = await _trailRepository.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken")); if (objVM.Trail == null) { return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <Location> npList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath); TrailsVM objVM = new TrailsVM() { NationalParkList = npList.Select(i => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem { Text = i.Name, Value = i.Id.ToString() }), Trail = new Trail() }; if (id == null) { //this will be true for insert or create return(View(objVM)); } // flow will continue here for update objVM.Trail = await _trailRepo.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault()); if (objVM == null) { return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> npList = await _npRepo.GetAllAsync(Static.NationalParkAPIPath, HttpContext.Session.GetString("JWToken")); TrailsViewModel objVM = new TrailsViewModel() { NationalParkList = npList.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }), //FLOW: We have to initialize trail() to prevent errors Trail = new Trail() }; if (id == null) { //FLOW: True for create return(View(objVM)); } //FLOW: Update method from here objVM.Trail = await _trailRepo.GetAsync(Static.TrailAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken")); if (objVM.Trail == null) { return(NotFound()); } else { return(View(objVM)); } }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> npList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath); TrailsVM objVM = new TrailsVM() { NationalParkList = npList.Select(i => new SelectListItem { Text = i.Name, Value = i.Id.ToString() }), Trail = new Trail() }; // this will be the case for create/insert if (id == null) { return(View(objVM)); } // Flow will come here for update objVM.Trail = await _trailRepo.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault()); if (objVM == null) { return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> GetAllNationalPark() { return(Json(new { data = await _npRepo.GetAllAsync(Static.NationalParkAPIPath, HttpContext.Session.GetString("JWToken")) })); }
public async Task <IActionResult> GetAllNationalParks() { return(Json(new { data = await _npRepo.GetAllAsync(StaticDetails.NationalParksApiPath, GetToken()) })); }
public async Task <IActionResult> Upsert(int?id)//Nullable ID as it is used for creating and updating { //Populate Dropdown with National Parks IEnumerable <NationalPark> npList = (IEnumerable <NationalPark>) await _npRepo.GetAllAsync(SD.NationalParkAPIPath, HttpContext.Session.GetString("JWToken")); //Populating Trails View Model with National Park list for dropdown TrailsVM objVM = new TrailsVM() { NationalParkList = npList.Select(i => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem { Text = i.Name, Value = i.Id.ToString() }), //Have to instantiate trails when accessing it from VM Trail = new Trail() }; if (id == null) { //This will be true for Insert/Create return(View(objVM)); } //Flow will enter this for Update objVM.Trail = await _trailRepo.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken")); if (objVM.Trail == null) { return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> Upsert(int?id) { IEnumerable <NationalPark> npList = await _parks.GetAllAsync(Globals.ApiNpUrl, HttpContext.Session.GetString("JWToken")); TrailsViewModel trailVM = new TrailsViewModel() { NationalParkList = npList.Select(i => new Microsoft.AspNetCore.Mvc.Rendering.SelectListItem { Text = i.Name, Value = i.Id.ToString() }) }; if (id == null) { return(View(trailVM)); } trailVM.Trail = await _trails.GetAsync(Globals.ApiTrialUrl, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken")); if (trailVM.Trail is null) { return(NotFound()); } return(View(trailVM)); }
public async Task <IActionResult> Upsert(int?id) { //populate dropdown IEnumerable <NationalPark> npList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath, HttpContext.Session.GetString("JWTToken")); TrailsVM objVM = new TrailsVM() { NationalParkList = npList.Select(_ => new SelectListItem { Text = _.Name, Value = _.Id.ToString() }) }; if (id == null) { //this will be true for Insert/Create return(View(objVM)); } //flow will come here for update objVM.Trail = await _trailRepo.GetAsync(SD.TrailAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWTToken")); if (objVM.Trail == null) { return(NotFound()); } return(View(objVM)); }
public async Task <IActionResult> GetAllNationalPark() { //WorkFlow var model = await _npRepo.GetAllAsync(SD.NationalParkAPIPath, HttpContext.Session.GetString("JWToken")); return(Json(new { data = model })); }
public async Task <IActionResult> Index() { IndexVM listOfParksAndTrails = new IndexVM() { NationalParkList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath, HttpContext.Session.GetString("JWToken")), TrailList = await _trailRepo.GetAllAsync(SD.TrailAPIPath, HttpContext.Session.GetString("JWToken")), }; return(View(listOfParksAndTrails)); }
public async Task <IActionResult> Index() { IndexVM obj = new IndexVM() { NationalParksList = await nationalParkRepository.GetAllAsync(SD.NationalParkAPIUrl, HttpContext.Session.GetString("JWTToken")), Trails = await trailRepository.GetAllAsync(SD.TrainAPIUrl, HttpContext.Session.GetString("JWTToken")) }; return(View(obj)); }
public async Task <IActionResult> Index() { HomeIndexViewModel listofParksAndTheirTrails = new HomeIndexViewModel() { NationalParks = await _nationalParkRepository.GetAllAsync(StaticDetails.NationalParkApiUrl), Trails = await _trailRepository.GetAllAsync(StaticDetails.TrailsApiUrl) }; return(View(listofParksAndTheirTrails)); }
public async Task <IActionResult> Index() { var index = new IndexViewModel() { Parks = await _parks.GetAllAsync(Globals.ApiNpUrl, HttpContext.Session.GetString("JWToken")), Trails = await _trails.GetAllAsync(Globals.ApiTrialUrl, HttpContext.Session.GetString("JWToken")) }; return(View(index)); }
public async Task <IActionResult> Index() { IndexVM viewModel = new IndexVM() { NationalParks = await _npRepository.GetAllAsync(SD.NationalParkAPIPath, Token), Trails = await _trailRepository.GetAllAsync(SD.TrailAPIPath, Token) }; return(View(viewModel)); }
public async Task <IActionResult> Index() { IndexVM ListOfParkAndTrails = new IndexVM() { NationalParkList = await _npRepo.GetAllAsync(SD.NationalParkAPIPath), TrailList = await _trailRepo.GetAllAsync(SD.TrailAPIPath) }; return(View(ListOfParkAndTrails)); }