Skip to content

Commit 73e473a

Browse files
committed
Bug fixes
Add task uuid only if uuid not provided. Fix batch update result sorting (again)
1 parent ec83caa commit 73e473a

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

RequestTests.paw

4.87 KB
Binary file not shown.

src/SimpleToDoService/Controllers/TasksController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,14 @@ public async System.Threading.Tasks.Task<IActionResult> BatchUpdate([FromBody] B
123123

124124
foreach(var task in instruction.ToCreate)
125125
{
126-
await CreateTask(task);
126+
var t = await CreateTask(task);
127+
repository.DetachTask(t);
127128
}
128129

129130
foreach(var task in instruction.ToUpdate)
130131
{
131-
await UpdateTask(task);
132+
var t = await UpdateTask(task);
133+
repository.DetachTask(t);
132134
}
133135

134136
foreach(var uuid in instruction.ToDelete)

src/SimpleToDoService/Database/Repositiory.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public interface IToDoRepository
1616
Task ReloadTask(Task task);
1717
Task CreateTask(Task task);
1818
Task UpdateTask(Task task);
19+
void DetachTask(Task task);
1920
bool DeleteTask(Guid uuid);
2021
bool DeleteTask(Task task);
2122
User CreateUser(User user);
@@ -55,13 +56,20 @@ public Task Task(Guid userUuid, Guid entryUuid)
5556

5657
public Task ReloadTask(Task task)
5758
{
58-
context.Entry(task).State = EntityState.Detached;
59+
DetachTask(task);
5960
return Task(task.UserUuid, task.Uuid);
6061
}
6162

63+
public void DetachTask(Task task)
64+
{
65+
context.Entry(task).State = EntityState.Detached;
66+
}
67+
6268
public Task CreateTask(Task task)
6369
{
64-
task.Uuid = new Guid();
70+
if (task.Uuid == null)
71+
task.Uuid = new Guid();
72+
6573
task.CreationDate = DateTime.Now.ToUniversalTime();
6674
task.PushNotifications = new List<PushNotification>();
6775
var entity = context.Tasks.Add(task);

0 commit comments

Comments
 (0)