public IActionResult PutClient(int id, [FromBody] ClientEntityModel model) { try { if (ModelState.IsValid) { model.Id = id; var newClient = _mapper.Map <ClientEntityModel, Client>(model); _repo.ModifyClient(newClient); if (_repo.SaveAll()) { return(Accepted($"/api/clients/{newClient.Id}", _mapper.Map <Client, ClientEntityModel>(newClient))); } } else { _logger.LogError($"Failed to put client with id {id} by model validation: {ModelState}"); return(BadRequest(ModelState)); } } catch (Exception e) { _logger.LogError($"Failed to put client with id {id}: {e}"); } return(BadRequest("Failed to edit client")); }