Table of Contents

Class BankRepository

Namespace
BankBackend.Repository
Assembly
BankBackend.dll
public class BankRepository : IBankRepository
Inheritance
BankRepository
Implements
Inherited Members

Constructors

BankRepository(BankContext)

constructor for dependency injection

public BankRepository(BankContext bankContext)

Parameters

bankContext BankContext

BankRepository(string)

public BankRepository(string connectionString)

Parameters

connectionString string

Methods

AddAccountToUser(int, int)

adds account with accountId to the account list of the user with userId

public User? AddAccountToUser(int accountId, int userId)

Parameters

accountId int
userId int

Returns

User

the updated user with the added account, null if the user does not exist

AddUserToAccount(int, int)

adds user with userId to the account list of the account with accountId

public Account? AddUserToAccount(int userId, int accountId)

Parameters

userId int
accountId int

Returns

Account

the updated account with the new user, null if account does not exist or if user does not exist

CreateAccount(Account)

uploads the account to database

public Account CreateAccount(Account account)

Parameters

account Account

Returns

Account

the account that was just created

CreateTransaction(Transaction)

uploads the transaction to database

public Transaction CreateTransaction(Transaction transaction)

Parameters

transaction Transaction

Returns

Transaction

the transaction that was just created

CreateUser(User)

uploads the user to database

public User CreateUser(User user)

Parameters

user User

Returns

User

the user that was just created

DeleteAccountById(int)

deletes the account with accountId

public Account? DeleteAccountById(int accountId)

Parameters

accountId int

Returns

Account

the account that was just deleted, null if the account does not exist

DeleteAccountUserByUserId(int, int)

deletes the user with userId from the account with accountId

public User? DeleteAccountUserByUserId(int accountId, int userId)

Parameters

accountId int
userId int

Returns

User

the user that was just deleted, null if the account does not exist, or if the account does not have an user with userId

DeleteTransactionByTransactionId(int)

deletes the transaction with transactionId

public Transaction? DeleteTransactionByTransactionId(int transactionId)

Parameters

transactionId int

Returns

Transaction

the transaction that was just deleted, null if the transaction does not exist

DeleteUserAccountByAccountId(int, int)

deletes the account with accountId from the user with userId

public Account? DeleteUserAccountByAccountId(int userId, int accountId)

Parameters

userId int
accountId int

Returns

Account

the account that was just deleted, null if user does not exist, or the user does not have an account with accountId

DeleteUserById(int)

deletes the user with userId

public User? DeleteUserById(int userId)

Parameters

userId int

Returns

User

the user that was just deleted, null if the user does not exist

GetAccountByAccountId(int)

find an account with accountId

public Account? GetAccountByAccountId(int accountId)

Parameters

accountId int

Returns

Account

the account with accountId, null if account does not exist

GetAccountsByUserId(int)

find all the accounts of the user with userId

public List<Account>? GetAccountsByUserId(int userId)

Parameters

userId int

Returns

List<Account>

a list containing all the accounts, null if user does not exist

GetAllAccounts()

find all existing accounts in the database

public List<Account> GetAllAccounts()

Returns

List<Account>

list containing all existing accounts, empty list if non exists

GetAllTransactions()

find all existing transactions in the database

public List<Transaction> GetAllTransactions()

Returns

List<Transaction>

list containing all existing transactions, empty list if non exists

GetAllUsers()

find all existing users in the database

public List<User> GetAllUsers()

Returns

List<User>

a list containing all existing users, empty list if non exists

GetPrimaryAccountsByUserId(int)

find all the accounts that the user with accountId is a primary user

public List<Account>? GetPrimaryAccountsByUserId(int userId)

Parameters

userId int

Returns

List<Account>

a list containing all the primary accounts, null if user does not exist

GetTransactionByTransactionId(int)

find a transaction with transactionId

public Transaction? GetTransactionByTransactionId(int transactionId)

Parameters

transactionId int

Returns

Transaction

the transaction with transactionId, null if transaction does not exist

GetTransactionsByFromAccountId(int)

public List<Transaction> GetTransactionsByFromAccountId(int fromAccountId)

Parameters

fromAccountId int

Returns

List<Transaction>

GetTransactionsByToAccountId(int)

public List<Transaction> GetTransactionsByToAccountId(int toAccountId)

Parameters

toAccountId int

Returns

List<Transaction>

GetUserByUserId(int)

find a user with userId

public User? GetUserByUserId(int userId)

Parameters

userId int

Returns

User

the user with the Id, null if user does not exist

GetUserByUsername(string)

find a user with username

public User? GetUserByUsername(string username)

Parameters

username string

Returns

User

the user with the username, null if user does not exist

GetUsersByAccountId(int)

find all the users of the account with accountId

public List<User>? GetUsersByAccountId(int accountId)

Parameters

accountId int

Returns

List<User>

a list containing all the users, null if account does not exist

UpdateBalance(int, double)

updates the balance of the account with accountId to balance

public Account? UpdateBalance(int accountId, double balance)

Parameters

accountId int
balance double

Returns

Account

the updated account with the new balance, null if the account does not exist

UpdatePassword(int, string)

updates the password of user with userId to password

public User? UpdatePassword(int userId, string password)

Parameters

userId int
password string

Returns

User

the updated user with the new password, null if the user does not exist

UpdatePrimaryUser(int, int)

replaces the primary user of the account with accountId with userId

public Account? UpdatePrimaryUser(int accountId, int userId)

Parameters

accountId int
userId int

Returns

Account

the updated account with the new primary user, null if account doesnot exist or if user does not exist

UpdateUsername(int, string)

updates the name of the user with userId to name

public User? UpdateUsername(int userId, string username)

Parameters

userId int
username string

Returns

User

the updated user with the new username, null if the user does not exist