db.Database.AddIgnore C# (CSharp) Method

AddIgnore() public method

public AddIgnore ( int accId, int ignoreId ) : bool
accId int
ignoreId int
return bool
        public bool AddIgnore(int accId, int ignoreId)
        {
            List<int> x = GetIgnoreds(accId);
            x.Add(ignoreId);
            string s = Utils.GetCommaSepString(x.ToArray());
            MySqlCommand cmd = CreateQuery();
            cmd.CommandText = "UPDATE accounts SET ignored=@newignored WHERE id=@accId";
            cmd.Parameters.AddWithValue("@newignored", s);
            cmd.Parameters.AddWithValue("@accId", accId);
            if (cmd.ExecuteNonQuery() == 0)
                return false;
            return true;
        }

Usage Example

示例#1
0
        public void EditAccountList(RealmTime time, EditAccountListPacket pkt)
        {
            List<int> list;
            if (pkt.AccountListId == LOCKED_LIST_ID)
                list = Locked;
            else if (pkt.AccountListId == IGNORED_LIST_ID)
                list = Ignored;
            else return;
            if (list == null)
                list = new List<int>();
            Player player = Owner.GetEntity(pkt.ObjectId) as Player;
            if (player == null) return;
            int accId = player.client.Account.AccountId;
            var db = new Database();
            //if (pkt.Add && list.Count < 6)
            //    list.Add(accId);
            //else
            //    list.Remove(accId);

            if (pkt.Add)
            {
                list.Add(accId);
                if (pkt.AccountListId == LOCKED_LIST_ID)
                    db.AddLock(client.Account.AccountId, accId);
                if (pkt.AccountListId == IGNORED_LIST_ID)
                    db.AddIgnore(client.Account.AccountId, accId);
            }
            else
            {
                list.Remove(accId);
                if (pkt.AccountListId == LOCKED_LIST_ID)
                    db.RemoveLock(client.Account.AccountId, accId);
                if (pkt.AccountListId == IGNORED_LIST_ID)
                    db.RemoveIgnore(client.Account.AccountId, accId);
            }

            SendAccountList(list, pkt.AccountListId);
        }