Пример #1
0
        // Feature: Create new accounts
        // Requirements:
        //      Savings must have a minimum of 700
        //      Can't have more than 1 account of the same type
        public bool CreateAccount(BankAccount newBankAccount)
        {
            if (newBankAccount.AccountType == BankAccountType.Savings)
            {
                if (newBankAccount.Balance < 700)
                {
                    return(false);
                }
            }

            // Lecture:
            // Incur two round trips for consolidate business rules
            if (String.IsNullOrWhiteSpace(newBankAccount.Owner?.EntityId))
            {
                throw new Exception($"Invalid {nameof(BankAppUser.EntityId)}");
            }

            var userAccounts = _bankAccountService.GetBankAccounts(newBankAccount.Owner);

            foreach (var account in userAccounts)
            {
                if (account.AccountType == newBankAccount.AccountType)
                {
                    return(false);
                }
            }


            return(_bankAccountService.CreateAccount(newBankAccount));
        }
Пример #2
0
        public List <BankAccount> GetAccounts()
        {
            var accounts = new List <BankAccount>();
            var headers  = HttpContext.Current.Request.Headers;
            var username = GetUsernameFromAuthHeader(headers["Authorization"]);

            if (!string.IsNullOrWhiteSpace(username))
            {
                accounts = _bankAccountService.GetBankAccounts(username);
            }

            return(accounts);
        }
Пример #3
0
        public async Task <List <BankAccountVM> > GetBankAccounts(string userId)
        {
            try
            {
                var bankAccounts = await _bankAccountService.GetBankAccounts(userId);

                return(MapToViewModel(bankAccounts));
            }
            catch (Exception)
            {
                //Error handle
                return(null);
            }
        }
Пример #4
0
 private void FillComboboxesWithData()
 {
     cb_shop.DataContext        = shopService.GetShopsCollection();
     cb_bankAccount.DataContext = bankAccountService.GetBankAccounts();
 }
Пример #5
0
 private void LoadData()
 {
     grid_konta.DataContext = bankAccountService.GetBankAccounts();
 }
        public async Task <IActionResult> List()
        {
            var bankAccounts = _bankAccountService.GetBankAccounts();

            return(new JsonResult(bankAccounts));
        }