public IActionResult CreateNationalPark([FromBody] CategoryDto categoryDto) { if (categoryDto == null) { return(BadRequest(ModelState)); } if (_repository.CategoryExists(categoryDto.Name)) { ModelState.AddModelError("", "This category already exsist..!"); return(StatusCode(404, ModelState)); } var categoryObj = _mapper.Map <Category>(categoryDto); if (!_repository.CreateCategory(categoryObj)) { ModelState.AddModelError("", $"Something went wrong when creating a category {categoryObj.Name} or {categoryObj.Description}"); return(StatusCode(500, ModelState)); } return(Ok(categoryObj)); }