[HttpPut("{id}")]//ROUTE public IActionResult Update(int id, [FromBody] HobbyDto hobbyDto) { // map dto to entity and set id var hobby = _mapper.Map <Hobby>(hobbyDto); hobby.IdHobby = id; try { // save _hobbyService.Update(hobby); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }