public IActionResult DeleteNationalPark(int nationalParkId) { if (!_npRepo.NationalParkExists(nationalParkId)) { return(NotFound()); } var nationalParkObj = _npRepo.GetNationalPark(nationalParkId); if (!_npRepo.DeleteNationalPark(nationalParkObj)) { ModelState.AddModelError("", $"Something went wrong when deleting the record {nationalParkObj.Name}"); return(StatusCode(500, ModelState)); } return(NoContent()); }
public IActionResult DeleteNationalPark(int nationalParkId) { bool isExists = _nationalParkRepo.NationalParkExists(nationalParkId); if (!isExists) { return(NotFound()); } var objDto = _nationalParkRepo.GetNationalPark(nationalParkId); if (!_nationalParkRepo.DeleteNationalPark(objDto)) { ModelState.AddModelError(CommonText.MSG_RESPONSE, $"Có lỗi sảy ra khi xoá bản ghi {objDto.Name}"); return(StatusCode(StatusCodes.Status500InternalServerError, ModelState)); } return(NoContent()); }
public IActionResult DeleteNationalPark(int id) { if (!_npRepo.NationalParkExists(id)) { return(BadRequest(ModelState)); } var park = _npRepo.GetNationalPark(id); if (!_npRepo.DeleteNationalPark(park)) { ModelState.AddModelError("", "Something went wrong."); return(StatusCode(500, ModelState)); } return(NoContent()); }
public IActionResult DeleteNationalPark(int nationalParkId) { if (!npRepository.CheckExistNationalPark(nationalParkId)) { return(NotFound()); } var obj = npRepository.GetNationalPark(nationalParkId); if (!npRepository.DeleteNationalPark(obj)) { ModelState.AddModelError(string.Empty, $"Something Wrong{obj.Name}"); return(StatusCode(500, ModelState)); } return(NoContent()); }
public IActionResult DeleteNationalPark(int id) { if (!_repo.NationalParkExists(id)) { return(NotFound()); } var nationalParkObj = _repo.GetNationalPark(id); if (!_repo.DeleteNationalPark(nationalParkObj)) { ModelState.AddModelError("", $"Error on server was occurred during deleting a object which have given id, this object: {nationalParkObj}"); return(StatusCode(500, ModelState)); } return(NoContent()); }
public IActionResult DeleteNationalPark(int nationalparkId) { if (!_repository.NationalParkExists(nationalparkId)) { return(NotFound()); } var domianObject = _repository.GetNationalPark(nationalparkId); if (!_repository.DeleteNationalPark(domianObject)) { ModelState.AddModelError(string.Empty, $"Deleting record failed {domianObject.Name}"); return(StatusCode(500, ModelState)); } return(NoContent()); }
[HttpDelete("{parkId:int}", Name = "DeleteNationalPark")] // dont add space in value public IActionResult DeleteNationalPark(int parkId) { if (!_npRepo.NationalParkExists(parkId)) { return(NotFound()); } // add more validation like existense var parkObj = _npRepo.GetNationalPark(parkId); if (!_npRepo.DeleteNationalPark(parkObj)) { ModelState.AddModelError("", $"Something went wrong when deleting {parkObj.Name }"); return(StatusCode(500, ModelState)); } return(NoContent()); }
public IActionResult DeleteNationaPark(int nationalParkId) { var obj = _npRepo.GetNationalPark(nationalParkId); if (obj == null) { return(NotFound()); } var dltobj = _mapper.Map <NationalPark>(obj); var deleteobj = _npRepo.DeleteNationalPark(dltobj); if (!deleteobj) { ModelState.AddModelError("", $"Something went wrong when saving the record {dltobj.Name}"); } return(NoContent()); }
public IActionResult DeleteNationalPark(int nationalParkId) { //ModelState contains all related encountered errors if (!_npRepo.NationalParkExists(nationalParkId)) { return(NotFound()); } var nationalParkObj = _npRepo.GetNationalPark(nationalParkId); //If update was unsuccessful if (!_npRepo.DeleteNationalPark(nationalParkObj)) { ModelState.AddModelError("", $"Something went wrong when deleting the record {nationalParkObj.Name}"); return(StatusCode(500, ModelState)); } return(NoContent()); }
public IActionResult DeleteNationalPark(int id) { var nationalPark = _npRepository.GetNationalPark(id); if (nationalPark == null) { return(BadRequest(new { message = "Data could not be found!" })); } var succeed = _npRepository.DeleteNationalPark(id); if (succeed) { return(Ok(new { message = "Data is successfully deleted!" })); } else { return(BadRequest(new { message = "Data could not be deleted!" })); } }