This commit is contained in:
hz
2025-05-08 09:29:20 -05:00
parent 4f67e2b56f
commit c0a94f26d6
31 changed files with 1181 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using GameAuthApi.Models;
using Microsoft.Extensions.Configuration;
using MongoDB.Driver;
namespace GameAuthApi.Services;
public class SpawnableService
{
private readonly IMongoCollection<Spawnable> _spawnables;
public SpawnableService(IConfiguration config)
{
var client = new MongoClient(config["MongoDB:ConnectionString"]);
var db = client.GetDatabase(config["MongoDB:DatabaseName"]);
_spawnables = db.GetCollection<Spawnable>("Spawnables");
}
public async Task CreateAsync(Spawnable spawnable)
{
await _spawnables.InsertOneAsync(spawnable);
}
public async Task<List<Spawnable>> GetAllAsync()
{
return await _spawnables.Find(_ => true).ToListAsync();
}
}