public ActionResult CreateNationalPark([FromBody] NationalParkDto parkDto) { if (parkDto == null) { return(BadRequest(ModelState)); } if (_npRepo.NationalParkExists(parkDto.Name)) { ModelState.AddModelError(string.Empty, "Park Exists"); return(StatusCode(404, ModelState)); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var park = _mapper.Map <NationalPark>(parkDto); if (_npRepo.CreateNationalParkExists(park)) { return(CreatedAtAction("GetNationalParkById", new { id = park.Id }, park)); } ModelState.AddModelError(string.Empty, $"Something went wrong when saving the record {park.Name}"); return(StatusCode(500, ModelState)); }