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
repositoryIBankRepository
Methods
AddAccountUser(int, int, int)
public User AddAccountUser(int userId, int addedUser, int accountId)
Parameters
Returns
CreateAccount(Account)
public Account CreateAccount(Account account)
Parameters
accountAccount
Returns
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
userUser
Returns
- User
the created user
Deposit(int, int, double)
public Transaction Deposit(int userId, int accountId, double amount)
Parameters
Returns
GetAccountByAccountId(int)
public Account GetAccountByAccountId(int accountId)
Parameters
accountIdint
Returns
GetAccountsByUserId(int)
find
public List<Account> GetAccountsByUserId(int userId)
Parameters
userIdint
Returns
Exceptions
GetAllAccounts()
public List<Account> GetAllAccounts()
Returns
GetAllUsers()
finds all users
public List<User> GetAllUsers()
Returns
GetTransactionsByAccountId(int)
public List<Transaction> GetTransactionsByAccountId(int accountId)
Parameters
accountIdint
Returns
GetTransactionsByUserId(int)
public List<Transaction> GetTransactionsByUserId(int userId)
Parameters
userIdint
Returns
GetUserByUserId(int)
finds a user by userId
public User GetUserByUserId(int userId)
Parameters
userIdint
Returns
Exceptions
- UserIdNotFoundException
if a user with the userId does not exist
GetUserByUsername(string)
finds a user by username
public User GetUserByUsername(string username)
Parameters
usernamestring
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
Returns
Transfer(int, int, int, double)
public Transaction Transfer(int userId, int fromAccountId, int toAccountId, double amount)
Parameters
Returns
UpdateUserProfile(int, string, string)
public User UpdateUserProfile(int userId, string newUsername, string newPassword)
Parameters
Returns
ValidateLogin(string, string)
validates user loging with username andpassword
public User ValidateLogin(string username, string password)
Parameters
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)