public IActionResult Update(string id, NationalPark nationalParkIn) { var nationalPark = _nationalParkRepository.Get(id); if (nationalPark == null) { return(NotFound()); } _nationalParkRepository.Update(id, nationalParkIn); return(NoContent()); }
public IActionResult Update(int nationalParkId, NationalParkDTO nationalParkDTO) { if (nationalParkDTO == null || nationalParkId == 0) { return(BadRequest(ModelState)); } NationalPark nationalPark = _mapper.Map <NationalPark>(nationalParkDTO); if (!_nationalParkRepository.Update(nationalPark)) { ModelState.AddModelError("", $"Something went wrong saving the record {nationalPark.Name}"); return(StatusCode(500, ModelState)); } return(NoContent()); }
public IActionResult UpdateNationalPark(int nationalParkId, [FromBody] NationalParkDTO nationalParkDto) { //FLOW: NationalParkId (string input) should be the same as the id inside the dto if (nationalParkDto == null || nationalParkId != nationalParkDto.Id) { return(BadRequest(ModelState)); } var nationalParkObj = _mapper.Map <NationalPark>(nationalParkDto); if (!_npRepo.Update(nationalParkObj)) { ModelState.AddModelError("", $"Something went wrong when patching the record {nationalParkObj.Name}"); return(StatusCode(500, ModelState)); } //FLOW: Not returning any content after httppatch return(NoContent()); }