// 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(""); }
// 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); }
// 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); } }
// 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); }
// 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); }