public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark nationalPark = new NationalPark();

            if (id == 0)
            {
                return(View(nationalPark));
            }
            nationalPark = await nationalParkRepository.GetAsync(SD.NationalParkAPIUrl, id.GetValueOrDefault(), HttpContext.Session.GetString("JWTToken"));

            if (nationalPark == null)
            {
                return(NotFound());
            }
            return(View(nationalPark));
        }
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }

            NationalParkDto nationalParkDto = await _npRepo.GetAsync(_npUrl, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (nationalParkDto == null)
            {
                return(NotFound());
            }

            // NationalParkDto and NationalParkUpdateDto have the same properties, but we create both of them for the seprate of concerns.
            NationalParkUpdateDto nationalParkUpdateDto = new NationalParkUpdateDto()
            {
                Id          = nationalParkDto.Id,
                Name        = nationalParkDto.Name,
                State       = nationalParkDto.State,
                Picture     = nationalParkDto.Picture,
                Established = nationalParkDto.Established
            };

            return(View(nationalParkUpdateDto));
        }
示例#3
0
        public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark obj = new NationalPark();

            if (id == null)
            {
                return(View(obj));
            }
            obj = await _npRepo.GetAsync(SD.NationalParkAPIPath, id.GetValueOrDefault());

            if (obj == null)
            {
                return(NotFound());
            }
            return(View(obj));
        }
示例#4
0
        public async Task <IActionResult> Upsert(int?Id)
        {
            NationalPark nationalPark = new NationalPark();

            if (Id == null)
            {
                return(View(nationalPark));
            }
            nationalPark = await _nationalPark.GetAsync(StaticDetails.NationalParkApiUrl, Id.GetValueOrDefault());

            if (nationalPark == null)
            {
                return(NotFound());
            }
            return(View(nationalPark));
        }
        public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark obj = new NationalPark();

            if (id == null)
            {
                return(View(obj)); // insert or create
            }
            // flow come here for update
            obj = await _npRepo.GetAsync(SD.NationalParkAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWTToken"));

            if (obj == null)
            {
                return(NotFound());
            }
            return(View(obj));
        }
示例#6
0
        public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark obj = new NationalPark();

            if (id == null)
            {
                //will be true for inser/create
                return(View(obj));
            }
            //true for update
            obj = await _npRepo.GetAsync(StaticDetails.NationalParkAPIPath, id.GetValueOrDefault());

            if (obj == null)
            {
                return(NotFound());
            }
            return(View(obj));
        }
        public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark nationalPark = new NationalPark();

            if (id == null)
            {
                return(View(nationalPark));
            }

            nationalPark = await _npRepository.GetAsync(SD.NationalParkAPIPath, id.GetValueOrDefault(), Token);

            if (nationalPark == null)
            {
                return(NotFound());
            }

            return(View(nationalPark));
        }
        public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark obj = new NationalPark();

            if (id == null)
            {
                return(View(obj));
            }

            obj = await _nationalParkRepository.GetAsync(SD.NationalAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (obj == null)
            {
                return(NotFound());
            }

            return(View(obj));
        }
        public async Task <IActionResult> Upsert(int?id)
        {
            var obj = new NationalPark();

            if (id == null)
            {
                //For inserting the data
                return(View(obj));
            }
            //For updating
            obj = await _npRepo.GetAsync(SD.NationalParkAPIPath, id.GetValueOrDefault());

            if (obj == null)
            {
                return(NotFound());
            }
            return(View(obj));
        }
        public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark obj = new NationalPark();

            // this will be the case for create/insert
            if (id == null)
            {
                return(View(obj));
            }

            // Flow will come here for update
            obj = await _npRepo.GetAsync(SD.NationalParkAPIPath, id.GetValueOrDefault());

            if (obj == null)
            {
                return(NotFound());
            }
            return(View(obj));
        }
示例#11
0
        public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark obj = new NationalPark();

            if (id == null)
            {
                //this will be true for Insert/Create
                return(View(obj));
            }

            //Flow will come here for update
            obj = await _parkRepository.GetAsync(SD.NationalParkAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (obj == null)
            {
                return(NotFound());
            }
            return(View(obj));
        }
示例#12
0
        public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark park = new NationalPark();

            if (id is null)
            {
                //true for insert/create
                return(View(park));
            }
            // for update
            park = await _repository.GetAsync(Globals.ApiNpUrl, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (park is null)
            {
                return(NotFound());
            }

            return(View(park));
        }
        public async Task <IActionResult> Upsert(int?id)
        {
            var nationalPark = new NationalPark();

            if (id == null)
            {
                return(View(nationalPark));
            }

            nationalPark =
                await _npRepo.GetAsync(StaticDetails.NationalParksApiPath, id.GetValueOrDefault(), GetToken());

            if (nationalPark == null)
            {
                return(NotFound());
            }

            return(View(nationalPark));
        }
        public async Task <IActionResult> Upsert(int?id)//Nullable ID as it is used for creating and updating
        {
            NationalPark obj = new NationalPark();

            if (id == null)
            {
                //This will be true for Insert/Create
                return(View(obj));
            }

            //Flow will enter this for Update
            obj = await _npRepo.GetAsync(SD.NationalParkAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (obj == null)
            {
                return(NotFound());
            }
            return(View(obj));
        }
示例#15
0
        public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark nationalPark = new NationalPark();

            if (id == null)
            {
                return(View(nationalPark));
            }
            else
            {
                var token = HttpContext.Session.GetString("JwToken");
                nationalPark = await _npRepository.GetAsync(SD.NationalParkAPIPath, id.GetValueOrDefault(), token);

                if (nationalPark == null)
                {
                    return(NotFound());
                }
                return(View(nationalPark));
            }
        }
示例#16
0
        public async Task <IActionResult> Upsert(int?id)
        {
            Location obj = new Location();

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

            // flow will continue here for update
            obj = await _npRepo.GetAsync(SD.NationalParkAPIPath, id.GetValueOrDefault());

            if (obj == null)
            {
                return(NotFound());
            }

            return(View(obj));
        }
示例#17
0
        public async Task <IActionResult> Upsert(int?id)
        {
            // empty object
            NationalPark obj = new NationalPark();

            if (id == null)
            {
                // For Create/Insert
                return(View(obj));
            }

            obj = await _npRepo.GetAsync(SD.NationalParkAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (obj == null)
            {
                return(NotFound());
            }

            // For Update
            return(View(obj));
        }
示例#18
0
        public async Task <IActionResult> Upsert(int?id)
        {
            NationalPark obj = new NationalPark();

            if (id == null)
            {
                //FLOW: True for create
                return(View(obj));
            }
            //FLOW: Update method from here
            obj = await _npRepo.GetAsync(Static.NationalParkAPIPath, id.GetValueOrDefault(), HttpContext.Session.GetString("JWToken"));

            if (obj == null)
            {
                return(NotFound());
            }
            else
            {
                return(View(obj));
            }
        }