示例#1
0
        public void RemoveItemban(string regionName, string itemName)
        {
            if (string.IsNullOrWhiteSpace(itemName))
            {
                throw new ArgumentNullException(nameof(itemName));
            }
            RtRegion rt = GetRtRegionByName(regionName);

            if (rt == null)
            {
                throw new Exception("Invalid region!");
            }
            if (!rt.ItemIsBanned(itemName))
            {
                throw new Exception($"{itemName} is not banned in this region.");
            }
            var origin = rt.Itembans;

            if (rt.RemoveBannedItem(itemName) &&
                _database.Query("UPDATE RtRegions SET Itembans = @0 WHERE Id = @1", rt.Itembans, rt.Id) != 0)
            {
                return;
            }

            rt.Itembans = origin;
            throw new Exception("Database error: No affected rows.");
        }
示例#2
0
        public void RemoveItemban(RtRegion rt, string itemName)
        {
            if (!rt.ItemIsBanned(itemName))
            {
                return;
            }

            var origin = rt.Itembans;

            if (rt.RemoveBannedItem(itemName) &&
                _database.Query("UPDATE RtRegions SET Itembans = @0 WHERE Id = @1", rt.Itembans, rt.Id) != 0)
            {
                return;
            }

            rt.Itembans = origin;
            throw new Exception("Database error: No affected rows.");
        }