Updating initial Location crud endpoints to be global & restricted to SUPER role

This commit is contained in:
2026-01-20 17:13:12 -06:00
parent eb34e6692f
commit cdeea60e52
5 changed files with 7 additions and 35 deletions
@@ -15,26 +15,16 @@ public class LocationStore
var db = client.GetDatabase(dbName);
_col = db.GetCollection<Location>("Locations");
var ownerIndex = Builders<Location>.IndexKeys.Ascending(l => l.OwnerUserId);
_col.Indexes.CreateOne(new CreateIndexModel<Location>(ownerIndex));
}
public Task CreateAsync(Location location) => _col.InsertOneAsync(location);
public Task<List<Location>> GetForOwnerAsync(string ownerUserId) =>
_col.Find(l => l.OwnerUserId == ownerUserId).ToListAsync();
public Task<List<Location>> GetAllAsync() =>
_col.Find(Builders<Location>.Filter.Empty).ToListAsync();
public async Task<bool> DeleteForOwnerAsync(string id, string ownerUserId, bool allowAnyOwner)
public async Task<bool> DeleteAsync(string id)
{
var filter = Builders<Location>.Filter.Eq(l => l.Id, id);
if (!allowAnyOwner)
{
filter = Builders<Location>.Filter.And(
filter,
Builders<Location>.Filter.Eq(l => l.OwnerUserId, ownerUserId)
);
}
var result = await _col.DeleteOneAsync(filter);
return result.DeletedCount > 0;
}