Skip to content

Commit 75d58ea

Browse files
authored
Merge pull request #47 from Jackpieking/F8
fix(F8): Change some logic to repo
2 parents 7299e39 + 11cdce3 commit 75d58ea

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

Src/Core/F8/DataAccess/F8Repository.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)