Esempio n. 1
0
        public int Add(Transaction transaction)
        {
            _context.Transactions.Add(transaction);
            _context.SaveChanges();

            return(transaction.AccountNumber);
        }
Esempio n. 2
0
        // This set the LockFlag to lock by passing loginID
        public bool Lock(string id)
        {
            var login = Get(id);

            if (login == null)
            {
                return(false);
            }
            else
            {
                login.LockFlag = LockFlag.Locked;
                _context.SaveChanges();
                return(true);
            }
        }
Esempio n. 3
0
        public int Update(int id, Login user)
        {
            var newUser = _context.Logins.Find(user.UserID);

            if (newUser.IsLocked)
            {
                newUser.IsLocked = false;
            }
            else
            {
                newUser.IsLocked = true;
            }
            _context.Update(newUser);
            _context.SaveChanges();

            return(id);
        }
Esempio n. 4
0
        public override async Task <string> ExecuteAsync(NwbaContext _context)
        {
            var account = await _context.Accounts.FindAsync(AccountNumber);

            account.Balance = account.Balance + Amount;
            account.Transactions.Add(
                new Transaction
            {
                TransactionType    = (char)Models.TransactionType.Deposit,
                Amount             = Amount,
                Comment            = Comment,
                TransactionTimeUtc = DateTime.UtcNow
            });

            _context.SaveChanges();
            return("true");
        }
Esempio n. 5
0
        public int Update(int id, BillPay item)
        {
            var newBillpay = _context.BillPays.Find(id);

            if (newBillpay.IsLocked)
            {
                newBillpay.IsLocked = false;
            }
            else
            {
                newBillpay.IsLocked = true;
            }
            _context.Update(newBillpay);
            _context.SaveChanges();

            return(id);
        }
Esempio n. 6
0
        //logs the user in
        public async Task <IActionResult> Login(string loginID, string password)
        {
            //gets their login model
            var login = await _context.Logins.FindAsync(loginID);

            //checks if valid

            if (login != null)
            {
                //Logs the user in
                bool successfull = await login.LoginUser(_context, password, loginID, this);

                //Updates the login attempts
                login.UpdateLoginAttempts(_context, successfull);
            }

            _context.SaveChanges();


            //redirects to the main page
            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 7
0
        public async Task <IActionResult> CreateBillPay(BillPayViewModel billPayModel)
        {
            ModelState.Clear();
            //Validates and shows errors to the user if there are any
            Dictionary <string, string> errors = new Dictionary <string, string>();

            BillPay.IsValid(_context, billPayModel.BillPay, out errors);

            if (errors.Count > 0)
            {
                foreach (KeyValuePair <string, string> entry in errors)
                {
                    ModelState.AddModelError(entry.Key, entry.Value);
                }
            }

            if (!ModelState.IsValid)
            {
                return(await CreateBillPay());
            }

            //creates, adds and saves the new bill
            BillPay billPay = new BillPay()
            {
                AccountNumber = billPayModel.BillPay.AccountNumber,
                PayeeID       = billPayModel.BillPay.PayeeID,
                Amount        = billPayModel.BillPay.Amount,
                ScheduleDate  = billPayModel.BillPay.ScheduleDate,
                Period        = billPayModel.BillPay.Period,
                ModifyDate    = DateTime.UtcNow
            };

            //adds to database and saves
            _context.BillPay.Add(billPay);
            _context.SaveChanges();
            return(RedirectToAction("ViewAccounts", "Customer"));
        }
 public int Add(Transaction transaction)
 {
     _context.Transactions.Add(transaction);
     _context.SaveChanges();
     return(transaction.TransactionID);
 }