public TViewModel GetByUserAndGame <TViewModel>(string currentUserId, int gameId)
 {
     return(reviewsRepository.AllAsNoTracking()
            .Where(x => x.AuthorId == currentUserId && x.GameId == gameId)
            .To <TViewModel>()
            .FirstOrDefault());
 }
 public IEnumerable <TViewModel> GetRandom <TViewModel>(int count)
 {
     return(gamesRepository.AllAsNoTracking()
            .OrderBy(x => Guid.NewGuid())
            .To <TViewModel>()
            .Take(count)
            .ToList());
 }
Beispiel #3
0
 internal static async Task <bool> CheckIfPlayerHasLinkedSteamAccount(string userId, IDeletableEntityRepository <Player> playersRepository)
 {
     return(await playersRepository
            .AllAsNoTracking()
            .Where(p => p.Id == userId)
            .Include(p => p.Claims)
            .AnyAsync(p => p.Claims.Any(c => c.ClaimType == STEAM_ID_64_CLAIM_TYPE)));
 }
Beispiel #4
0
 internal static async Task <bool> CheckIfPlayerIsVACBanned(string userId, IDeletableEntityRepository <Player> playersRepository)
 {
     return(await playersRepository
            .AllAsNoTracking()
            .Where(p => p.Id == userId)
            .Include(p => p.Claims)
            .SelectMany(x => x.Claims)
            .AnyAsync(x => x.ClaimType == IS_VAC_BANNED_CLAIM_TYPE));
 }
Beispiel #5
0
 internal static async Task <bool> CheckIfPlayerHasAlreadyEnrolledATeam(string userId, int tournamentFormatId, IDeletableEntityRepository <Team> teamsRepository)
 {
     return(await teamsRepository
            .AllAsNoTracking()
            .Where(t => t.OwnerId == userId && t.TournamentFormatId == tournamentFormatId)
            .Include(t => t.TeamTableResults)
            .ThenInclude(ttr => ttr.TournamentTable)
            .ThenInclude(tt => tt.Tournament)
            .SelectMany(x => x.TeamTableResults.Select(y => y.TournamentTable.Tournament))
            .AnyAsync(x => x.AreSignupsOpen || x.IsActive));
 }
Beispiel #6
0
        internal static async Task <bool> CheckIfTeamIsFull(int teamId, IDeletableEntityRepository <Team> teamsRepository)
        {
            var team = await teamsRepository
                       .AllAsNoTracking()
                       .Include(t => t.TournamentFormat)
                       .Include(t => t.PlayerTeams)
                       .SingleOrDefaultAsync(x => x.Id == teamId);

            var playersCount = team
                               .PlayerTeams
                               .Count(x => x.IsDeleted == false);

            var  maxPlayers = team.TournamentFormat.TeamPlayersCount + TEAM_MAX_BACKUP_PLAYERS_COUNT;
            bool isFull     = playersCount >= maxPlayers;

            return(isFull);
        }
Beispiel #7
0
 internal static async Task <bool> CheckIfTournamentTableExists(int tournamentTableId, IDeletableEntityRepository <TournamentTable> tournamentTablesRepository)
 {
     return(await tournamentTablesRepository
            .AllAsNoTracking()
            .AnyAsync(tt => tt.Id == tournamentTableId));
 }
Beispiel #8
0
 internal static async Task <bool> CheckIfTeamExists(int teamId, IDeletableEntityRepository <Team> teamsRepository)
 {
     return(await teamsRepository
            .AllAsNoTracking()
            .AnyAsync(t => t.Id == teamId));
 }
Beispiel #9
0
 internal static async Task <bool> CheckIfPlayerExists(string userId, IDeletableEntityRepository <Player> playersRepository)
 {
     return(await playersRepository
            .AllAsNoTracking()
            .AnyAsync(x => x.Id == userId));
 }
Beispiel #10
0
 public int GetCount()
 {
     return(settingsRepository.AllAsNoTracking().Count());
 }