24 lines
713 B
C#
24 lines
713 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using SVSim.Database.Enums;
|
|
using SVSim.Database.Models;
|
|
|
|
namespace SVSim.Database.Repositories.Viewer;
|
|
|
|
public class ViewerRepository : IViewerRepository
|
|
{
|
|
protected readonly SVSimDbContext _dbContext;
|
|
|
|
public ViewerRepository(SVSimDbContext dbContext)
|
|
{
|
|
_dbContext = dbContext;
|
|
}
|
|
|
|
public async Task<Models.Viewer?> GetViewerBySocialConnection(SocialAccountType accountType, ulong socialId)
|
|
{
|
|
return _dbContext.Set<SocialAccountConnection>()
|
|
.AsNoTracking()
|
|
.Include(sac => sac.Viewer)
|
|
.FirstOrDefault(sac => sac.AccountType == accountType && sac.AccountId == socialId)
|
|
?.Viewer;
|
|
}
|
|
} |