public IActionResult Update(int id, [FromBody] ItemListUpdateModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // map model to entity and set id var itemList = _mapper.Map <ItemList>(model); itemList.Id = id; try { // update item list _itemListService.Update(itemList); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }