improve this, make more efficient, cache repeated calls in variables, less nesting too, use c# codeblock:

/// <summary>
        /// Checks whether or not this bank instance has enough items to accept a take operation.
        /// </summary>
        /// <param name="itemId">The ItemId to see if it can be taken away.</param>
        /// <param name="quantity">The quantity of above item to see if we can take away.</param>
        /// <returns>Whether or not the item can be taken away from the bank in the requested quantity.</returns>
        public bool CanTakeItem(Guid itemId, int quantity) => FindItemQuantity(itemId) >= quantity;

        public bool TryDepositItem(int slot, int amount, int destSlot = -1, bool sendUpdate = true)
        {
            //Permission Check
            if (mGuild != null)
            {
                var rank = Options.Instance.Guild.Ranks[Math.Max(0, Math.Min(Options.Instance.Guild.Ranks.Length - 1, mPlayer.GuildRank))];
                if (!rank.Permissions.BankDeposit && mPlayer.GuildRank != 0)
                {
                    PacketSender.SendChatMsg(mPlayer, Strings.Guilds.NotAllowedDeposit.ToString(mGuild.Name), ChatMessageType.Bank, CustomColors.Alerts.Error);
                    return false;
                }
            }

            var itemBase = mPlayer.Items[slot].Descriptor;
            if (itemBase != null)
            {
                if (mPlayer.Items[slot].ItemId != Guid.Empty)
                {
                    if ((!itemBase.CanBank && mGuild == null) || (!itemBase.CanGuildBank && mGuild != null))
                    {
                        PacketSender.SendChatMsg(mPlayer, Strings.Items.nobank, ChatMessageType.Bank, CustomColors.Items.Bound);
                        return false;
                    }

                    lock (mLock)
                    {
                        // if stackable, make sure the user actually has this many items or more.
                        if (itemBase.IsStackable)
                        {
                            if (!mPlayer.CanTakeItem(itemBase.Id, amount))
                            {
                                amount = mPlayer.FindInventoryItemQuantity(itemBase.Id);
                            }
                        }
                        else
                        {
                            amount = 1;
                        }

                        var bankSlot = mBank?[destSlot];

                        if (CanStoreItem(new Item(itemBase.Id, amount), destSlot) &&
                            itemBase.IsStackable &&
                            itemBase.Id == bankSlot.ItemId &&
                            amount + bankSlot.Quantity <= bankSlot.Descriptor.MaxBankStack)
                        {
                            PutItem(new Item(itemBase.Id, amount), destSlot, sendUpdate);
                            mPlayer.TryTakeItem(itemBase.Id, amount, ItemHandling.Normal, sendUpdate);

                            if (sendUpdate)
                            {
                                PacketSender.SendInventoryItemUpdate(mPlayer, slot);
                            }

                            if (mGuild != null)
                            {
                                DbInterface.Pool.QueueWorkItem(mGuild.Save);
                            }

                            return true;
                        }

                        // Bank slot is full or item is not stackable, find another slot!
                        if (!IsSlotOpen(destSlot))
                        {
                            destSlot = FindOpenSlot();
                        }

                        if (destSlot < 0 || destSlot > Options.Instance.Bank.MaxSlots) // Bank is full.
                        {
                            PacketSender.SendChatMsg(mPlayer, Strings.Banks.banknospace, ChatMessageType.Bank,
                                CustomColors.Alerts.Error);
                            return false;
                        }

                        PutItem(mPlayer.Items[slot], destSlot, sendUpdate);
                        mPlayer.Items[slot].Set(Item.None);
                        mPlayer.EquipmentProcessItemLoss(slot);

                        if (sendUpdate)
                        {
                            PacketSender.SendInventoryItemUpdate(mPlayer, slot);
                        }

                        if (mGuild != null)
                        {
                            DbInterface.Pool.QueueWorkItem(mGuild.Save);
                        }

                        return true;
                    }
                }
            }

            PacketSender.SendChatMsg(mPlayer, Strings.Banks.depositinvalid, ChatMessageType.Bank,
                CustomColors.Alerts.Error);
            return false;
        }