Table of Contents

Class BankService

Namespace
BankBackend.Service
Assembly
BankBackend.dll
public class BankService : IBankService
Inheritance
BankService
Implements
Inherited Members

Constructors

BankService(IBankRepository)

constructor for dependency injection

public BankService(IBankRepository repository)

Parameters

repository IBankRepository

Methods

AddAccountUser(int, int, int)

public User AddAccountUser(int userId, int addedUser, int accountId)

Parameters

userId int
addedUser int
accountId int

Returns

User

CreateAccount(Account)

public Account CreateAccount(Account account)

Parameters

account Account

Returns

Account

CreateUser(User)

creates a user and returns the created user if the given user has any an UserId other than 0 the UserId is ignored

public User CreateUser(User user)

Parameters

user User

Returns

User

the created user

Deposit(int, int, double)

public Transaction Deposit(int userId, int accountId, double amount)

Parameters

userId int
accountId int
amount double

Returns

Transaction

GetAccountByAccountId(int)

public Account GetAccountByAccountId(int accountId)

Parameters

accountId int

Returns

Account

GetAccountsByUserId(int)

find

public List<Account> GetAccountsByUserId(int userId)

Parameters

userId int

Returns

List<Account>

Exceptions

UserIdNotFoundException

GetAllAccounts()

public List<Account> GetAllAccounts()

Returns

List<Account>

GetAllUsers()

finds all users

public List<User> GetAllUsers()

Returns

List<User>

all users

GetTransactionsByAccountId(int)

public List<Transaction> GetTransactionsByAccountId(int accountId)

Parameters

accountId int

Returns

List<Transaction>

GetTransactionsByUserId(int)

public List<Transaction> GetTransactionsByUserId(int userId)

Parameters

userId int

Returns

List<Transaction>

GetUserByUserId(int)

finds a user by userId

public User GetUserByUserId(int userId)

Parameters

userId int

Returns

User

Exceptions

UserIdNotFoundException

if a user with the userId does not exist

GetUserByUsername(string)

finds a user by username

public User GetUserByUsername(string username)

Parameters

username string

Returns

User

user with the username

Exceptions

UsernameNotFoundException

if a user with the username does not exist

RemoveAccountUser(int, int)

public User RemoveAccountUser(int userId, int accountId)

Parameters

userId int
accountId int

Returns

User

Transfer(int, int, int, double)

public Transaction Transfer(int userId, int fromAccountId, int toAccountId, double amount)

Parameters

userId int
fromAccountId int
toAccountId int
amount double

Returns

Transaction

UpdateUserProfile(int, string, string)

public User UpdateUserProfile(int userId, string newUsername, string newPassword)

Parameters

userId int
newUsername string
newPassword string

Returns

User

ValidateLogin(string, string)

validates user loging with username andpassword

public User ValidateLogin(string username, string password)

Parameters

username string
password string

Returns

User

the logged in user if credentials are correct

Exceptions

UsernameNotFoundException

if user name does not exist

InvalidPasswordException

if password is incorrect

Withdraw(int, int, double)

public Transaction Withdraw(int userId, int accountId, double amount)

Parameters

userId int
accountId int
amount double

Returns

Transaction