Ejemplo n.º 1
0
        public async Task <IActionResult> Deposit(int userID, int accountID, double amount, string accountType, double interest, DateTime dateCreated, DateTime dateInterest, int imf, double balance)
        {
            var account = new Accounts();

            account.userID       = userID;
            account.accountID    = accountID;
            account.accountType  = accountType;
            account.interest     = interest;
            account.dateCreated  = dateCreated;
            account.dateInterest = dateInterest;
            account.imf          = imf;
            account.balance      = balance + amount;

            if (accountID != account.accountID)
            {
                return(RedirectToAction("ErrorPage", "MainMenu"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var transaction = new Transaction();
                    transaction.userID               = account.userID;
                    transaction.accountID            = account.accountID;
                    transaction.transactionDate      = DateTime.Now;
                    transaction.transactionProcessed = "Deposited $" + amount + " into " + account.accountType + " (" + accountID + ")";

                    _context.Update(account);
                    await _context.SaveChangesAsync();

                    _context.Update(transaction);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountsExists(account.accountID))
                    {
                        return(RedirectToAction("ErrorPage", "MainMenu"));
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Accounts", new { userId = account.userID }));
            }
            return(View(account));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("userID,fname,lname,dob,ssn,address,username,password")] Customers customers)
        {
            if (id != customers.userID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomersExists(customers.userID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customers));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("userID,accountID,dateCreated,accountType,balance,interest,dateInterest,imf")] Accounts accounts)
        {
            if (id != accounts.accountID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accounts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountsExists(accounts.accountID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accounts));
        }