public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            var userName = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Name).Value;

            cacct = await _context.CheckingAccounts.FirstOrDefaultAsync(c => c.Username == userName);

            sacct = await _context.SavingAccounts.FirstOrDefaultAsync(s => s.Username == userName);

            if (cacct != null)
            {
                cacct.Balance += transactionHistories.Amount;
                _context.CheckingAccounts.Update(cacct);
                transactionHistories.CheckingAccountNumber = cacct.CheckingAccountNumber;
            }

            if (sacct != null)
            {
                sacct.Balance -= (transactionHistories.Amount + transactionHistories.TransactionFee);
                _context.SavingAccounts.Update(sacct);
                transactionHistories.SavingAccountNumber = sacct.SavingAccountNumber;
            }

            transactionHistories.TransactionFee    = 5.0M;
            transactionHistories.TransactionTypeId = 101;

            _context.TransactionHistories.Add(transactionHistories);

            await _context.SaveChangesAsync();

            return(RedirectToPage("./TransactionHistories"));
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Loan).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoanExists(Loan.LoanId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }


            if (cacct != null)
            {
                cacct.Balance -= transactionHistories.Amount;
                _context.CheckingAccounts.Update(cacct);
                transactionHistories.CheckingAccountNumber = cacct.CheckingAccountNumber;
            }

            if (sacct != null)
            {
                sacct.Balance += transactionHistories.Amount;
                _context.SavingAccounts.Update(sacct);
                transactionHistories.SavingAccountNumber = sacct.SavingAccountNumber;
            }

            transactionHistories.TransactionFee    = 0;
            transactionHistories.TransactionTypeId = 100;

            _context.TransactionHistories.Add(transactionHistories);

            await _context.SaveChangesAsync();

            return(RedirectToPage("./TransactionHistories"));
        }
Esempio n. 4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            var userName = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.Name).Value;

            loan.UserName = userName;

            _context.Loan.Add(loan);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Esempio n. 5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Loan = await _context.Loan.FindAsync(id);

            if (Loan != null)
            {
                _context.Loan.Remove(Loan);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 6
0
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AspNetRoles = await _context.AspNetRoles.FindAsync(id);

            if (AspNetRoles != null)
            {
                _context.AspNetRoles.Remove(AspNetRoles);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }