Skip to content

Commit

Permalink
fixed update bug
Browse files Browse the repository at this point in the history
  • Loading branch information
VaclavKucera committed Nov 27, 2024
1 parent ffd37b9 commit f36d4a5
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public void Create(ToDoItem item)
public ToDoItem? ReadById(int id) => context.ToDoItems.Find(id);
public void Update(ToDoItem item)
{
context.Entry(item).CurrentValues.SetValues(item);
var foundItem = context.ToDoItems.Find(item.ToDoItemId) ?? throw new Exception($"Item with ID {item.ToDoItemId} not found.");

Check warning on line 24 in ToDoList/src/ToDoList.Persistence/Repositories/ToDoItemsRepository.cs

View workflow job for this annotation

GitHub Actions / build

Exception type System.Exception is not sufficiently specific (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2201)
context.Entry(foundItem).CurrentValues.SetValues(item);
context.SaveChanges();
}

Expand Down

0 comments on commit f36d4a5

Please sign in to comment.