Skip to content

Commit

Permalink
Closes #60
Browse files Browse the repository at this point in the history
Add missing list change in update of an item
  • Loading branch information
mtracewicz committed Sep 27, 2024
1 parent cd3369d commit 5eea349
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion backend/bruno/KSummarized/ToDo/Items/Update.bru
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ body:json {
"tags": [],
"subtasks": []
}
]
],
"listId": 2
}
}
13 changes: 10 additions & 3 deletions backend/src/infrastructure/Data/TodoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public async Task<bool> UpdateItem(Guid user, TodoItem item)
existingItem.Deadline = item.Deadline;
existingItem.Notes = item.Notes;
existingItem.Compleated = item.Compleated;
existingItem.ListId = item.ListId;
foreach (var st in item.Subtasks)
{
var existingSubtask = existingItem.Subtasks.FirstOrDefault(st => st.Id == st.Id);
Expand All @@ -188,7 +189,8 @@ public async Task<bool> UpdateItem(Guid user, TodoItem item)
Deadline = st.Deadline,
Notes = st.Notes,
Tags = [],
Subtasks = []
Subtasks = [],
ListId = item.ListId
};
existingItem.Subtasks.Add(newSubtask);
}
Expand All @@ -198,6 +200,7 @@ public async Task<bool> UpdateItem(Guid user, TodoItem item)
existingSubtask.Deadline = st.Deadline;
existingSubtask.Notes = st.Notes;
existingSubtask.Compleated = st.Compleated;
existingSubtask.ListId = item.ListId;
}
}
var existingTags = existingItem.Tags.ToList();
Expand Down Expand Up @@ -229,7 +232,9 @@ private static TodoItem MapTodoItem(infrastructure.Data.TodoItemModel item)
Deadline = item.Deadline,
Notes = item.Notes,
Subtasks = item.Subtasks?.Select(st => MapSubtask(st)).ToList() ?? [],
Tags = item.Tags?.Select(t => new core.Tag() { Id = t.Id, Name = t.Name }).ToList() ?? []
Tags = item.Tags?.Select(t => new core.Tag() { Id = t.Id, Name = t.Name }).ToList() ?? [],
ListId = item.ListId,
Compleated = item.Compleated
};
}

Expand All @@ -242,7 +247,9 @@ private static TodoItem MapSubtask(infrastructure.Data.TodoItemModel subtask)
Deadline = subtask.Deadline,
Notes = subtask.Notes,
Subtasks = [],
Tags = subtask.Tags?.Select(t => new core.Tag() { Id = t.Id, Name = t.Name }).ToList() ?? []
Tags = subtask.Tags?.Select(t => new core.Tag() { Id = t.Id, Name = t.Name }).ToList() ?? [],
ListId = subtask.ListId,
Compleated = subtask.Compleated
};
}
}

0 comments on commit 5eea349

Please sign in to comment.