/// <summary>
        /// Creates a new account
        /// </summary>
        /// <param name="user"><see cref="User"/> entity</param>
        /// <returns>Created <see cref="Account"/> entity</returns>
        public Account CreateAccount(User user)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            var account = new Account
            {
                Balance = 0m,
                User = user
            };

            _accountRepository.Add(account);

            return account;
        }
 public override void Init()
 {
     base.Init();
     Account = BankService.CreateAccount(User);
 }
        /// <summary>
        /// Creates a new transaction
        /// </summary>
        /// <param name="transactionType">The type of the transaction</param>
        /// <param name="account"><see cref="Account"/> entity</param>
        /// <param name="amount">Amount</param>
        /// <returns>Created transaction</returns>
        public Transaction CreateTransaction(TransactionType transactionType, Account account, Decimal amount)
        {
            if (transactionType == TransactionType.NotSpecified)
                throw new ArgumentException("The transaction's type cann't be not specified");

            if (account == null)
                throw new ArgumentNullException("account");

            if (amount <= 0)
                throw new ArgumentException("Amount cann't be less or equal 0");

            if (!DoesTheAccountExist(account))
                throw new ArgumentException(String.Format("Account with ID {0} wasn't found", account.AccountId));

            var transaction = new Transaction
            {
                Account = account,
                Amount = amount,
                Type = transactionType,
                IsCommited = false
            };

            _transactionRepository.Add(transaction);

            return transaction;
        }
        /// <summary>
        /// Checks exist the account in the collection of the accounts
        /// </summary>
        /// <param name="account"><see cref="Account"/> entity</param>
        /// <returns>TRUE - if the account exists, FALSE - if the account doesn't exist</returns>
        private Boolean DoesTheAccountExist(Account account)
        {
            if (account == null)
                throw new ArgumentNullException("account");

            return _accountRepository.Query().Any(x => x.AccountId == account.AccountId);
        }
        /// <summary>
        /// Removes an account
        /// </summary>
        /// <param name="account"><see cref="Account"/> entity</param>
        public void RemoveAccount(Account account)
        {
            if (account == null)
                throw new ArgumentNullException("account");

            if (!DoesTheAccountExist(account))
                throw new ArgumentException(String.Format("Account with ID {0} wasn't found", account.AccountId));

            // first delete all transactions
            var transactions = _transactionRepository.Query().Where(x => x.Account.AccountId == account.AccountId);
            _transactionRepository.DeleteRange(transactions);

            // delete account
            _accountRepository.Delete(account);
        }
        /// <summary>
        /// Gets transaction by account
        /// </summary>
        /// <param name="account"><see cref="Account"/> entity</param>
        /// <returns>Collection of <see cref="Transaction"/> entities</returns>
        public IEnumerable<Transaction> GetTransactionsByAccount(Account account)
        {
            if (account == null)
                throw new ArgumentNullException("account");

            return _transactionRepository.Query().Where(x => x.Account.AccountId == account.AccountId);
        }