using MongoDB.Driver; using SumaTube.Infra.MongoDB.Documents.UserPlan; namespace SumaTube.Infra.MongoDB.Repositories.UserPlan { public class PersonUserRepository { private readonly IMongoCollection _collection; public PersonUserRepository(IMongoDatabase database) { _collection = database.GetCollection("PersonUsers"); } public async Task GetByIdAsync(string id) { return await _collection.Find(p => p.Id == id).FirstOrDefaultAsync(); } public async Task> GetAllAsync() { return await _collection.Find(_ => true).ToListAsync(); } public async Task CreateAsync(PersonUserDocument PersonUserDocument) { await _collection.InsertOneAsync(PersonUserDocument); } public async Task UpdateAsync(PersonUserDocument PersonUserDocument) { await _collection.ReplaceOneAsync(p => p.Id == PersonUserDocument.Id, PersonUserDocument); } public async Task DeleteAsync(string id) { await _collection.DeleteOneAsync(p => p.Id == id); } } }