public async void DeleteAllPropertyKeys(int id) { Property property = Properties[(id - 1)]; List <Inventory> items = await InventoryRepository.GetInventoryItemByName(property.Name + " key"); // --- Go through all actively loaded properties and remove the key foreach (Inventory item in items) { foreach (KeyValuePair <Client, Player> player in Player.PlayerData) { Player ply = Player.PlayerData[player.Key]; Inventory itm = ply.Inventory.FirstOrDefault(i => i.Id == item.Id); if (itm == null) { continue; } ply.Inventory.Remove(itm); } foreach (Property prop in Properties) { Inventory itm = prop.Inventory?.FirstOrDefault(i => i.Id == item.Id); if (itm == null) { continue; } prop.Inventory.Remove(itm); } foreach (KeyValuePair <NetHandle, Vehicle> vehicle in Vehicle.VehicleData) { Vehicle veh = Vehicle.VehicleData[vehicle.Key]; Inventory itm = veh.TrunkItems?.FirstOrDefault(i => i.Id == item.Id); if (itm == null) { continue; } veh.TrunkItems.Remove(itm); } InventoryRepository.RemoveInventoryItem(item); } }