public async Task <IActionResult> Create(CompanyDto company) { if (await _companyRepo.IsCompanyNameExistsAsync(company.Name)) { return(BadRequest("Company name already exists")); } var result = await _companyRepo.CreateAsync(company); if (result > 0) { return(Created(string.Empty, new { Id = result })); } var modelStateDic = new ModelStateDictionary(); modelStateDic.AddModelError("create", $"{_companyRepo.InternalExeption?.Message}"); if (_companyRepo.InternalExeption?.InnerException != null) { modelStateDic.AddModelError("create innerException", $"{_companyRepo.InternalExeption?.InnerException.Message}"); } return(BadRequest(modelStateDic)); }