public IActionResult Post([FromBody] TeamCategoryViewModel model) { try { if (ModelState.IsValid) { var newCategory = new TeamCategory() { Name = model.Name }; repository.AddTeamCategory(newCategory); if (repository.SaveAll()) { return(Ok("New team category has been saved")); } } else { return(BadRequest(ModelState)); } } catch (Exception exception) { Console.WriteLine(exception); } return(BadRequest("Failed to save new team category")); }