Exemplo n.º 1
0
        public virtual void Init()
        {
            var accountRepository = new AccountRepositoryStub();
            var transactionRepository = new TransactionRepositoryStub();

            RulesService = new BusinessRulesService();
            BankService = new BankService(accountRepository, transactionRepository, RulesService);
            User = CreateUser();
        }
Exemplo n.º 2
0
        protected User CreateUser()
        {
            var user = new User
            {
                FirstName = "John",
                LastName = "Johnson"
            };

            return user;
        }
Exemplo n.º 3
0
        /// <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;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets all accounts for the user
        /// </summary>
        /// <param name="user"><see cref="User"/> entity</param>
        /// <returns>Collection of the <see cref="Account"/> entities for the user</returns>
        public IEnumerable<Account> GetAccountsForUser(User user)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            var accounts = _accountRepository.GetAccountsForUser(user);
            return accounts;
        }