Beispiel #1
0
        //  Gets the password stored in the database
        public async Task <string> getPassword(string Name)
        {
            moodTable bankRecord = (await bankRecordTable.Where(p => p.Name == Name).ToEnumerableAsync()).Single();

            if (bankRecord != null)
            {
                return(bankRecord.Password);
            }

            return("");
        }
Beispiel #2
0
        // Retrieves the bank balance of a specified person
        public async Task <double> getBalance(string Name)
        {
            moodTable bankRecord = (await bankRecordTable.Where(p => p.Name == Name).ToEnumerableAsync()).Single();

            if (bankRecord != null)
            {
                return(bankRecord.Balance);
            }

            return(0);
        }
Beispiel #3
0
        // Updates the bank balance of a specific person in the database by adding or subtracting
        public async Task updateBalance(string Name, double amount)
        {
            // Finds the row in the database table where the name matches the given name
            moodTable bankRecord = (await bankRecordTable.Where(p => p.Name == Name).ToEnumerableAsync()).Single();

            if (bankRecord != null)
            {
                bankRecord.Balance += amount;
                await bankRecordTable.UpdateAsync(bankRecord);
            }
        }
Beispiel #4
0
        // Adds a new person to the bank database
        public async Task AddBankRecord(string userName, string password)
        {
            moodTable record = new moodTable()
            {
                Name     = userName,
                Balance  = 0,
                Password = password
            };

            await this.bankRecordTable.InsertAsync(record);
        }
Beispiel #5
0
        // Deletes an account from the bank database
        public async Task DeleteBankRecord(string Name)
        {
            moodTable bankRecord = (await bankRecordTable.Where(p => p.Name == Name).ToEnumerableAsync()).Single();

            await this.bankRecordTable.DeleteAsync(bankRecord);
        }