using Newsbot.Collector.Domain.Entities; using Newsbot.Collector.Domain.Interfaces; namespace Newsbot.Collector.Database.Repositories; public class RefreshTokenTable : IRefreshTokenRepository { private readonly DatabaseContext _context; public RefreshTokenTable(string connectionString) { _context = new DatabaseContext(connectionString); } public RefreshTokenTable(DatabaseContext context) { _context = context; } public void Add(RefreshTokenEntity entity) { _context.RefreshTokens.Add(entity); _context.SaveChanges(); } public RefreshTokenEntity? Get(string token) { return _context.RefreshTokens.SingleOrDefault(x => x.Token == token); } public void UpdateTokenIsUsed(string token) { var entity = Get(token); if (entity is null) { return; } entity.Used = true; _context.RefreshTokens.Update(entity); _context.SaveChanges(); } }