public IActionResult CreateNationalPart([FromBody] NationalParkDTO model) { if (model == null) { return(BadRequest(ModelState)); } if (ModelState.IsValid == false) { return(BadRequest(ModelState)); } if (nationalParkRepository.NationalparkExit(model.Name)) { ModelState.AddModelError("", "This Park is already exist!"); return(StatusCode(404, ModelState)); } var data = mapper.Map <NationalPark>(model); if (!nationalParkRepository.CreateNationalPark(data)) { ModelState.AddModelError("", $"Something is Wrong when saving the park {data.Name}"); return(StatusCode(500, ModelState)); } //return Ok(); //return CreatedAtRoute("GetNationPark", new { parkId = data.Id }, data); // If we have Specify the APi VErsion then return(CreatedAtRoute("GetNationPark", new { version = HttpContext.GetRequestedApiVersion().ToString(), parkId = data.Id }, data)); }