public async Task <IActionResult> Post([FromBody] StateDTO stateData) { try { if (ModelState.IsValid) { var newState = _mapper.Map <StateDTO, State>(stateData); newState.CreatedDate = DateTimeOffset.UtcNow; await _repository.CreateAsync(newState); return(Ok(newState)); } return(Json(ModelState)); } catch (Exception ex) { return(BadRequest(_errorHandler.JsonErrorMessage((int)HttpStatusCode.BadRequest, ex.Message + ex.InnerException.Message))); } }