public void RemoveProjban(string regionName, short projId) { RtRegion rt = GetRtRegionByName(regionName); if (rt == null) { throw new Exception("Invalid region!"); } var p = new Projectile(); p.SetDefaults(projId); if (!rt.ProjectileIsBanned(projId)) { throw new Exception($"{p.name} is not banned in this region."); } var origin = rt.Projbans; if (rt.RemoveBannedProjectile(projId) && _database.Query("UPDATE RtRegions SET Projbans = @0 WHERE Id = @1", rt.Projbans, rt.Id) != 0) { return; } rt.Projbans = origin; throw new Exception("Database error: No affected rows."); }
public void AddProjban(string regionName, short projId) { RtRegion rt = GetRtRegionByName(regionName); if (rt == null) { throw new Exception("Invalid region!"); } var p = new Projectile(); p.SetDefaults(projId); if (rt.ProjectileIsBanned(projId)) { throw new Exception($"{p.name} has been already banned in this region."); } var modified = new StringBuilder(rt.Projbans); if (modified.Length != 0) { modified.Append(','); } modified.Append(projId); if (_database.Query("UPDATE RtRegions SET Projbans = @0 WHERE Id = @1", modified, rt.Id) == 0) { throw new Exception("Database error: No affected rows."); } rt.Projbans = modified.ToString(); }
public void RemoveProjban(RtRegion rt, short projId) { if (!rt.ProjectileIsBanned(projId)) { return; } var origin = rt.Projbans; if (rt.RemoveBannedProjectile(projId) && _database.Query("UPDATE RtRegions SET Projbans = @0 WHERE Id = @1", rt.Projbans, rt.Id) != 0) { return; } rt.Projbans = origin; throw new Exception("Database error: No affected rows."); }
public void AddProjban(RtRegion rt, short projId) { if (rt.ProjectileIsBanned(projId)) { return; } var modified = new StringBuilder(rt.Projbans); if (modified.Length != 0) { modified.Append(','); } modified.Append(projId); _database.Query("UPDATE RtRegions SET Projbans = @0 WHERE Id = @1", modified, rt.Id); rt.Projbans = modified.ToString(); }