Esempio n. 1
0
        public int Update(int id, Payee payee)
        {
            _context.Update(payee);
            _context.SaveChanges();

            return(id);
        }
        public int Update(int id, Transaction transaction)
        {
            _context.Update(transaction);
            _context.SaveChanges();

            return(id);
        }
Esempio n. 3
0
        public int Update(int id, BillPay billPay)
        {
            _context.Update(billPay);
            _context.SaveChanges();

            return(id);
        }
        public int Update(int id, Customer customer)
        {
            _context.Update(customer);
            _context.SaveChanges();

            return(id);
        }
Esempio n. 5
0
        public int Update(int id, Account account)
        {
            _context.Update(account);
            _context.SaveChanges();

            return(id);
        }
Esempio n. 6
0
        public int Update(int id, Login login)
        {
            _context.Update(login);
            _context.SaveChanges();

            return(id);
        }
Esempio n. 7
0
        public async Task AddYearAsync(int id, IBWContext _context)
        {
            var billpay = _context.BillPays.Find(id);

            billpay.ScheduleDate = billpay.ScheduleDate.AddYears(1);
            _context.Add(billpay);
            _context.Update(billpay);
            await _context.SaveChangesAsync();
        }
Esempio n. 8
0
        //if it is not once change the schedule date after transaction
        private async Task AddQuaterAsync(int id, IBWContext _context)
        {
            var billpay = _context.BillPays.Find(id);

            billpay.ScheduleDate = billpay.ScheduleDate.AddMonths(3);
            _context.Add(billpay);
            _context.Update(billpay);
            await _context.SaveChangesAsync();
        }
Esempio n. 9
0
        //update acount after the bill is paied
        public async Task UpDateAcc(int id, decimal amount, IBWContext _context)
        {
            var account = _context.Accounts.Find(id);

            account.Balance   -= (amount + .2m);
            account.ModifyDate = DateTime.UtcNow;
            _context.Add(account);
            _context.Update(account);
            await _context.SaveChangesAsync();
        }
Esempio n. 10
0
        async Task UpdateBlock(IBWContext _context)
        {
            IList <Login> logins = await _context.Logins.ToListAsync();

            foreach (Login login in logins)
            {
                if (login.ModifyDate.AddSeconds(30).CompareTo(DateTime.UtcNow) <= 0)
                {
                    login.Block = false;
                    _context.Add(login);
                    _context.Update(login);
                }

                await _context.SaveChangesAsync();
            }
        }
Esempio n. 11
0
        public async Task <IActionResult> Modify(int id, [Bind("BillPayID,AccountNumber,PayeeID,Amount,ScheduleDate,Period,Block")] BillPay billPay)
        {
            if (id != billPay.BillPayID)
            {
                return(NotFound());
            }
            if (HttpContext.Session.GetInt32("Block").Value == 1)
            {
                billPay.Block = true;
            }

            if (MiscellaneousExtensionUtilities.HasMoreThanTwoDecimalPlaces(billPay.Amount))
            {
                ModelState.AddModelError(nameof(Transaction.Amount), "your should only have 2 decimal places in your amount.");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    billPay.ScheduleDate = TimeZoneInfo.ConvertTimeToUtc(billPay.ScheduleDate);
                    _context.Add(billPay);
                    _context.Update(billPay);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BillPayExists(billPay.BillPayID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            List <Period> periods = Enum.GetValues(typeof(Period)).Cast <Period>().ToList();

            // set transaction view bag
            ViewBag.Periods           = new SelectList(periods);
            ViewData["AccountNumber"] = new SelectList(_context.Accounts, "AccountNumber", "AccountNumber", billPay.AccountNumber);
            ViewData["PayeeID"]       = new SelectList(_context.Payees, "PayeeID", "PayeeName", billPay.PayeeID);
            return(View(billPay));
        }
        public async Task <IActionResult> Login(string UserID, string password)
        {
            var login = await _context.Logins.Include(x => x.Customer).
                        FirstOrDefaultAsync(x => x.UserID == UserID);


            if (login.Block)
            {
                ModelState.AddModelError("LoginFailed", "Your account has been locked.");
                HttpContext.Session.SetInt32("Block", 0);
                return(View(new Login {
                    UserID = UserID
                }));
            }


            if (login == null || !PBKDF2.Verify(login.PasswordHash, password))
            {
                HttpContext.Session.SetInt32("Block", HttpContext.Session.GetInt32("Block").Value + 1);
                ModelState.AddModelError("LoginFailed", String.Format("Login failed, please try again. left attempt: {0}", 3 - HttpContext.Session.GetInt32("Block").Value));
                if (HttpContext.Session.GetInt32("Block").Value == 3)
                {
                    login.Block      = true;
                    login.ModifyDate = DateTime.UtcNow;
                    _context.Add(login);
                    _context.Update(login);
                    await _context.SaveChangesAsync();
                }
                return(View(new Login {
                    UserID = UserID
                }));
            }


            // Login customer.
            HttpContext.Session.SetInt32(nameof(Customer.CustomerID), login.CustomerID);
            HttpContext.Session.SetString(nameof(Customer.CustomerName), login.Customer.CustomerName);
            HttpContext.Session.SetString(nameof(Model.Login.UserID), UserID);

            return(RedirectToAction("Index", "ATM"));
        }