Fixing 500 error for real
This commit is contained in:
@@ -58,6 +58,9 @@ public class LocationService
|
||||
|
||||
public virtual async Task AddItemToLocationAsync(string locationId, string itemId)
|
||||
{
|
||||
if (!ObjectId.TryParse(locationId, out _) || !ObjectId.TryParse(itemId, out _))
|
||||
return;
|
||||
|
||||
var idFilter = Builders<Location>.Filter.Eq(l => l.Id, locationId);
|
||||
|
||||
// if the Content array is null, initialize it first
|
||||
@@ -71,6 +74,9 @@ public class LocationService
|
||||
|
||||
public virtual async Task RemoveItemFromLocationAsync(string locationId, string itemId)
|
||||
{
|
||||
if (!ObjectId.TryParse(locationId, out _) || !ObjectId.TryParse(itemId, out _))
|
||||
return;
|
||||
|
||||
var filter = Builders<Location>.Filter.Eq(l => l.Id, locationId) & Builders<Location>.Filter.Ne("Content", BsonNull.Value);
|
||||
var update = Builders<Location>.Update.Pull(l => l.Content, itemId);
|
||||
await _locations.UpdateOneAsync(filter, update);
|
||||
|
||||
Reference in New Issue
Block a user