public IActionResult CreateTrail([FromBody] TrailInsertDTO TrailDTO) { if (TrailDTO == null) { return(BadRequest(ModelState)); } if (trailRepository.CheckExistTrail(TrailDTO.Name)) { ModelState.AddModelError(string.Empty, "Trail Exists"); return(StatusCode(404, ModelState)); } var obj = mapper.Map <Trail>(TrailDTO); if (!trailRepository.CreateTrail(obj)) { ModelState.AddModelError(string.Empty, $"Something Wrong{obj.Name}"); return(StatusCode(500, ModelState)); } return(CreatedAtRoute("GetTrail", new { TrailId = obj.Id }, obj)); }