public IActionResult Create(Family item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { return(Ok(_familyRepository.Create(item))); } catch { return(BadRequest(ModelState)); //or you can throw new Exception } }