Ejemplo n.º 1
0
        public IActionResult UpdateNationalPark(int id, [FromBody] NationalParkDto parkDto)
        {
            if (parkDto == null || parkDto.Id != id)
            {
                return(BadRequest(ModelState));
            }

            var park = _mapper.Map <NationalPark>(parkDto);

            if (!_npRepo.NationalParkExists(park.Id))
            {
                return(NotFound(ModelState));
            }
            if (!_npRepo.UpdateNationalParkExists(park))
            {
                ModelState.AddModelError(string.Empty, $"Somthing went wrong when update this park {park.Name}");
                return(StatusCode(500, ModelState));
            }
            return(NoContent());
        }