Пример #1
0
        /// <summary>
        /// Constructs a new BankAccount from the supplied database object.
        /// </summary>
        public BankAccount(Journal.XBankAccount Account) {
           // this.DatabaseBankAccount = Account;
            _flags = Account.Flags;
            this.BankAccountK = Account.BankAccountK;
            this.BankAccountName = Account.UserAccountName;
            this.WorldID = Account.WorldID;

            //refresh the balance from the database, money will be set when the async I/O finishes
            //this.DatabaseBankAccount.GetBalanceFromDatabaseAsync().ContinueWith((balanceResult) => {
            //    _money = balanceResult.Result;
            //});
        }
Пример #2
0
        /// <summary>
        /// Enables or disables the account.
        /// </summary>
        public void SetAccountEnabled(int CallerID, bool Enabled)
        {
            Journal.BankAccountFlags _newFlags = this.Flags;

            if (Enabled == false)
            {
                _newFlags &= (~Journal.BankAccountFlags.Enabled);
            }
            else
            {
                _newFlags |= Journal.BankAccountFlags.Enabled;
            }
        }
Пример #3
0
        /// <summary>
        /// Constructs a new BankAccount from the supplied database object.
        /// </summary>
        public BankAccount(Journal.XBankAccount Account)
        {
            // this.DatabaseBankAccount = Account;
            _flags               = Account.Flags;
            this.BankAccountK    = Account.BankAccountK;
            this.BankAccountName = Account.UserAccountName;
            this.WorldID         = Account.WorldID;

            //refresh the balance from the database, money will be set when the async I/O finishes
            //this.DatabaseBankAccount.GetBalanceFromDatabaseAsync().ContinueWith((balanceResult) => {
            //    _money = balanceResult.Result;
            //});
        }
Пример #4
0
        /// <summary>
        /// Updates the bank account flags from a database.  Called when enabled changes, etc.
        /// </summary>
        internal async Task <Journal.BankAccountFlags?> UpdateFlagsAsync(Journal.BankAccountFlags NewFlags)
        {
            int numberOfRecordsUpdated = await SEconomyPlugin.Database.AsyncConnection.ExecuteAsync("update bankaccount set flags = @0 where bankaccountk = @1", NewFlags, this.BankAccountK);

            // number of rows affected
            if (numberOfRecordsUpdated == 1)
            {
                this.Flags = NewFlags;

                return(NewFlags);
            }

            //In a lambda there is no way for it to infer what type (null) is to anything other than object.
            //We just help it along a bit by telling it we're talking about a nullable
            return((BankAccountFlags?)null);
        }