Beispiel #1
0
 public async Task <BanData> GetBanAsync(int ban)
 {
     return(BanData.FromBan(await _dbContext.Bans
                            .Include(x => x.JobBans)
                            .Include(x => x.SourceNavigation).
                            FirstOrDefaultAsync(x => x.Id == ban)));
 }
Beispiel #2
0
        public async Task <IEnumerable <BanData> > GetBansForSourceAsync(int source, bool onlyActive = false)
        {
            var query = _dbContext.Bans
                        .Include(x => x.JobBans)
                        .Include(x => x.SourceNavigation)
                        .Where(x => x.Source == source);

            if (onlyActive)
            {
                query = query.Where(x => x.UnbannedBy == null && (x.Expires == null || x.Expires > DateTime.UtcNow));
            }
            return(await query.OrderByDescending(x => x.BannedOn)
                   .Select(x => BanData.FromBan(x))
                   .ToListAsync());
        }
Beispiel #3
0
        public async Task <IEnumerable <BanData> > GetBansForKeyAsync(string key, int?source, bool onlyActive = false)
        {
            var ckey  = KeyUtilities.GetCanonicalKey(key);
            var query = _dbContext.Bans
                        .Include(x => x.JobBans)
                        .Include(x => x.SourceNavigation)
                        .Where(x => x.CKey == ckey);

            if (source.HasValue)
            {
                query = query.Where(x => x.Source == source);
            }
            if (onlyActive)
            {
                query = query.Where(x => x.UnbannedBy == null && (x.Expires == null || x.Expires > DateTime.UtcNow));
            }
            return(await query.OrderByDescending(x => x.BannedOn)
                   .Select(x => BanData.FromBan(x))
                   .ToListAsync());
        }