Example #1
0
        public IActionResult Delete(int nationalParkId)
        {
            if (!_nationalParkRepository.ExsistsById(nationalParkId))
            {
                return(NotFound());
            }
            NationalPark nationalPark = (NationalPark)_nationalParkRepository.GetById(nationalParkId);

            if (!_nationalParkRepository.Delete(nationalPark))
            {
                ModelState.AddModelError("", $"Something went wrong deleting the record {nationalPark}");
                return(StatusCode(500, ModelState));
            }
            return(NoContent());
        }
        public IActionResult DeleteNationalPark(int nationalParkId)
        {
            //FLOW: if park does not exist return notfound(404)
            if (!_npRepo.NationalParkExists(nationalParkId))
            {
                return(NotFound());
            }
            var nationalParkObj = _npRepo.GetNationalPark(nationalParkId);

            if (!_npRepo.Delete(nationalParkObj))
            {
                ModelState.AddModelError("", $"Something went wrong when deleting the record {nationalParkObj.Name}");
                return(StatusCode(500, ModelState));
            }
            //FLOW: Not returning any content after httpdelete
            return(NoContent());
        }