File size: 732 Bytes
7535af1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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();
    }
}