public IActionResult Create(Example exampleToCreate) { if (exampleToCreate == null) { return(BadRequest(ModelState)); } if (exampleRepository.ExampleExists(exampleToCreate.Id) == true) { ModelState.AddModelError("", $"{exampleToCreate.Id} already exists"); return(StatusCode(422)); } if (!ModelState.IsValid) { return(BadRequest()); } if (!exampleRepository.Create(exampleToCreate)) { ModelState.AddModelError("", $"Create Error"); return(StatusCode(500)); } return(Ok("Create Success")); }