Beispiel #1
0
        public override async Task AddServerBanAsync(ServerBanDef serverBan)
        {
            await using var db = await GetDbImpl();

            db.PgDbContext.Ban.Add(new PostgresServerBan
            {
                Address        = serverBan.Address,
                HWId           = serverBan.HWId?.ToArray(),
                Reason         = serverBan.Reason,
                BanningAdmin   = serverBan.BanningAdmin?.UserId,
                BanTime        = serverBan.BanTime.UtcDateTime,
                ExpirationTime = serverBan.ExpirationTime?.UtcDateTime,
                UserId         = serverBan.UserId?.UserId
            });

            await db.PgDbContext.SaveChangesAsync();
        }
        public override async Task AddServerBanAsync(ServerBanDef serverBan)
        {
            await using var db = await GetDbImpl();

            string?addrStr = null;

            if (serverBan.Address is { } addr)
            {
                addrStr = $"{addr.address}/{addr.cidrMask}";
            }

            db.SqliteDbContext.Ban.Add(new SqliteServerBan
            {
                Address        = addrStr,
                Reason         = serverBan.Reason,
                BanningAdmin   = serverBan.BanningAdmin?.UserId,
                BanTime        = serverBan.BanTime.UtcDateTime,
                ExpirationTime = serverBan.ExpirationTime?.UtcDateTime,
                UserId         = serverBan.UserId?.UserId
            });

            await db.SqliteDbContext.SaveChangesAsync();
        }
 public Task AddServerBanAsync(ServerBanDef serverBan)
 {
     return(_db.AddServerBanAsync(serverBan));
 }
 public abstract Task AddServerBanAsync(ServerBanDef serverBan);