Skip to content

Commit

Permalink
Add tracker to unregistered trackers when removed
Browse files Browse the repository at this point in the history
  • Loading branch information
mads256h committed Dec 7, 2023
1 parent b052cb5 commit 68834e4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CentralHub.Api/Services/TrackerRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ public async Task RemoveTrackerAsync(TrackerDto trackerDto, CancellationToken ca
}

room.Trackers.Remove(trackerDto);
var unregisteredTracker = await UnregisteredTrackersMutex.Lock(unregisteredTrackers =>
{
var unregisteredTracker = new UnregisteredTrackerDto()
{
BluetoothMacAddress = trackerDto.BluetoothMacAddress,
WifiMacAddress = trackerDto.WifiMacAddress,
};
unregisteredTrackers.Add(unregisteredTracker);
return unregisteredTracker;
}, cancellationToken);
_applicationDbContext.Rooms.Update(room);
try
{
Expand All @@ -120,6 +130,10 @@ public async Task RemoveTrackerAsync(TrackerDto trackerDto, CancellationToken ca
// Set the roomDto to unchanged
_applicationDbContext.Rooms.Attach(room).State = EntityState.Unchanged;
room.Trackers.Add(trackerDto);
await UnregisteredTrackersMutex.Lock(unregisteredTrackers =>
{
unregisteredTrackers.Remove(unregisteredTracker);
}, cancellationToken);
throw;
}
}
Expand Down

0 comments on commit 68834e4

Please sign in to comment.