File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed
Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -37,15 +37,33 @@ await _appContext
3737
3838 try
3939 {
40- var rowsAffected = await _appContext
40+ // Remove list
41+ await _appContext
4142 . Set < TodoTaskListEntity > ( )
4243 . Where ( list => list . Id == listId )
4344 . ExecuteDeleteAsync ( ct ) ;
4445
45- if ( rowsAffected == 0 )
46- {
47- throw new DbUpdateException ( ) ;
48- }
46+ // Remove all task steps
47+ await _appContext
48+ . Set < TodoTaskEntity > ( )
49+ . Where ( task => task . TodoTaskListId == listId )
50+ . Select ( task => task . Id )
51+ . ForEachAsync (
52+ async taskId =>
53+ {
54+ await _appContext
55+ . Set < TodoTaskStepEntity > ( )
56+ . Where ( taskStep => taskStep . TodoTaskId == taskId )
57+ . ExecuteDeleteAsync ( ct ) ;
58+ } ,
59+ ct
60+ ) ;
61+
62+ // Remove all tasks
63+ await _appContext
64+ . Set < TodoTaskEntity > ( )
65+ . Where ( task => task . TodoTaskListId == listId )
66+ . ExecuteDeleteAsync ( ct ) ;
4967
5068 await dbTransaction . CommitAsync ( ct ) ;
5169 }
You can’t perform that action at this time.
0 commit comments