Stuff works

This commit is contained in:
gamer147
2024-09-08 10:27:12 -04:00
parent 7e4bce9ac5
commit ac3b002d74
14 changed files with 157 additions and 87 deletions

View File

@@ -5,4 +5,5 @@ namespace SVSim.Database.Repositories.Viewer;
public interface IViewerRepository
{
Task<Models.Viewer?> GetViewerBySocialConnection(SocialAccountType accountType, ulong socialId);
Task<Models.Viewer?> GetViewerWithSocials(ulong id);
}

View File

@@ -15,10 +15,16 @@ public class ViewerRepository : IViewerRepository
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)
return (await _dbContext.Set<SocialAccountConnection>()
.AsNoTracking()
.Include(sac => sac.Viewer)
.FirstOrDefaultAsync(sac => sac.AccountType == accountType && sac.AccountId == socialId))
?.Viewer;
}
public async Task<Models.Viewer?> GetViewerWithSocials(ulong id)
{
return await _dbContext.Set<Models.Viewer>().AsNoTracking().Include(viewer => viewer.SocialAccountConnections)
.FirstOrDefaultAsync(viewer => viewer.Id == id);
}
}