Spaces:
Sleeping
Sleeping
SaluAi / src /Infrastructure /TelegramSaaS.Infrastructure /Persistence /Repositories /UserRepository.cs
| using System.Threading.Tasks; | |
| using MongoDB.Driver; | |
| using TelegramSaaS.Application.Common.Interfaces.Persistence; | |
| using TelegramSaaS.Domain.Entities; | |
| namespace TelegramSaaS.Infrastructure.Persistence.Repositories; | |
| public class UserRepository : MongoRepository<User>, IUserRepository | |
| { | |
| public UserRepository(MongoDbContext context) : base(context, "Users") | |
| { | |
| } | |
| public async Task<User?> GetByTelegramChatIdAsync(long chatId) | |
| { | |
| return await Collection.Find(x => x.TelegramChatId == chatId).FirstOrDefaultAsync(); | |
| } | |
| public async Task<User?> GetByReferralCodeAsync(string referralCode) | |
| { | |
| return await Collection.Find(x => x.ReferralCode == referralCode).FirstOrDefaultAsync(); | |
| } | |
| } | |