Ejemplo n.º 1
0
        public async Task <IActionResult> AddBankAccount(Guid payeeId)
        {
            var banks = await _context.Banks.ToListAsync();

            Guid bankId       = banks.FirstOrDefault().ID;
            var  bankbranches = await _context.BankBranches
                                .Where(b => b.BankID == bankId)
                                .OrderBy(n => n.Name)
                                .ToListAsync();

            PayeeBankAccountViewModel viewModel = new PayeeBankAccountViewModel
            {
                PayeeID        = payeeId,
                BankList       = new SelectList(banks, "ID", "Name", banks.FirstOrDefault()),
                BankBranchList = new SelectList(bankbranches, "ID", "Name", bankbranches.FirstOrDefault())
            };

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddBankAccount(PayeeBankAccountViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                BankAccount      bankaccount      = viewModel.BankAccount;
                PayeeBankAccount payeebankaccount = new PayeeBankAccount();

                bankaccount.ID = Guid.NewGuid();
                _context.Add(bankaccount);
                await _context.SaveChangesAsync();

                payeebankaccount.BankAccountID = bankaccount.ID;
                payeebankaccount.PayeeID       = viewModel.PayeeID;
                _context.Add(payeebankaccount);
                await _context.SaveChangesAsync();

                //Guid payeeItemId = GetPayeeItemId(payeebankaccount.PayeeID);

                return(RedirectToAction("PayeeBankAccounts", new { payeeId = viewModel.PayeeID }));
            }
            return(View(viewModel));
        }