using Microsoft.Extensions.Options; using MongoDB.Driver; using Prospect.Server.Api.Config; using Prospect.Server.Api.Services.Database.Models; namespace Prospect.Server.Api.Services.Database; public class DbEntityService : BaseDbService { public DbEntityService(IOptions settings) : base(settings, nameof(PlayFabEntity)) { } public async Task FindAsync(string userId) { return await Collection.Find(user => user.UserId == userId).SingleOrDefaultAsync(); } // Admin back-office: list every entity (title_player_account). public async Task> GetAllAsync() { return await Collection.Find(_ => true).ToListAsync(); } private async Task CreateAsync(string userId) { var user = new PlayFabEntity { UserId = userId }; await Collection.InsertOneAsync(user); return user; } public async Task FindOrCreateAsync(string userId) { return await FindAsync(userId) ?? await CreateAsync(userId); } }