public IActionResult Post(long id, [FromBody] Person body) { try { if (body == null) { return(BadRequest("Person can't be null.")); } long partnerId = _peopleRepository.GetPartnerId(id); if (partnerId == -1) { return(BadRequest($"Partner not found for person with id {id}. Child can't be added")); } long childId = _peopleRepository.AddChild(body, new List <long> { id, partnerId }); if (childId == -1) { return(StatusCode((int)HttpStatusCode.InternalServerError, $"Child couldn't be added. An error occurred.")); } else { return(Created($"/people/{childId}", childId)); } } catch (Exception ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } }