public async Task <IActionResult> Add([FromBody] ClientRegister client) { if (ModelState.IsValid) { int UserId = -1; if (int.TryParse(HttpContext.User.FindFirst("user_id").Value, out UserId)) { var clientObj = client.getClient(UserId); if (clientObj != null) { var result = await clientRepository.AddAsync(clientObj); if (result != null) { return(CreatedAtAction("Add", result)); } } } return(BadRequest("Error")); } return(BadRequest(ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage)); }