Esempio n. 1
0
        public async Task Invoke(HttpContext context, IBWContext dbcontext)
        {
            var    request = context.Request.Path.Value;
            String path    = request.ToLower();

            if (path.Contains("login") || path.Contains("api") || path == "/" || path.Contains("block") || path.Contains("expire"))
            {
                await _next.Invoke(context);
            }

            else if (context.Session.GetInt32(nameof(Customer.CustomerID)) != null)
            {
                Login login = dbcontext.Logins.Find(context.Session.GetInt32(nameof(Customer.CustomerID)).Value);
                if (login.Block)
                {
                    context.Response.Redirect($"https://localhost:44310/Block/Block");
                    context.Session.Clear();
                }
                else
                {
                    await _next.Invoke(context);
                }
            }
            else
            {
                context.Response.Redirect($"https://localhost:44310/Expire/Expire");
            }
        }
Esempio n. 2
0
        //if bill pay is once delete it after transaction
        private async Task DeleteOnce(int id, IBWContext _context)
        {
            var billpay = _context.BillPays.Find(id);

            _context.Remove(billpay);
            await _context.SaveChangesAsync();
        }
Esempio n. 3
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. 4
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. 5
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. 6
0
        //bill pay method
        async Task UpdateBillPay(IBWContext _context)
        {
            IList <BillPay> billpays = await _context.BillPays.ToListAsync();

            foreach (BillPay billpay in billpays)
            {
                // check date
                if (billpay.ScheduleDate.CompareTo(DateTime.UtcNow) <= 0 && !billpay.Block)
                {
                    Account     account     = _context.Accounts.Find(billpay.AccountNumber);
                    Transaction transaction = TransactionBuilder.BuildTransaction(billpay);
                    Transaction service     = TransactionBuilder.BuildTransaction(transaction);
                    // check if there is enough balance
                    if (TransferExtensionUtilities.checkBalance(transaction, account))
                    {
                        var transactions = _context.Transactions;
                        transactions.Add(transaction);
                        transactions.Add(service);
                        int id    = billpay.BillPayID;
                        int accId = billpay.AccountNumber;
                        await UpDateAcc(accId, billpay.Amount, _context);

                        await _context.SaveChangesAsync();

                        switch (billpay.Period)
                        {
                        case Period.M:
                            await AddMonthAsync(id, _context);

                            break;

                        case Period.Y:
                            await AddYearAsync(id, _context);

                            break;

                        case Period.Q:
                            await AddQuaterAsync(id, _context);

                            break;

                        case Period.O:
                            await DeleteOnce(id, _context);

                            break;
                        }
                    }
                }
            }
        }
Esempio n. 7
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. 8
0
        async void UnBlock(Object state)
        {
            var Context = new IBWContext(serviceProvider.CreateScope().ServiceProvider.GetRequiredService <DbContextOptions <IBWContext> >());

            await UpdateBlock(Context);
        }
Esempio n. 9
0
 public LoginManager(IBWContext context)
 {
     _context = context;
 }
Esempio n. 10
0
 public CustomersController(IBWContext context) => _context = context;
Esempio n. 11
0
 public BillPaysController(IBWContext context)
 {
     _context = context;
 }
Esempio n. 12
0
 public ATMController(IBWContext context) => _context = context;
 public CustomerManager(IBWContext context)
 {
     _context = context;
 }
 //session key to restore user information.
 public AccountsController(IBWContext context) => _context = context;
Esempio n. 15
0
 public AccountManager(IBWContext context)
 {
     _context = context;
 }
 public TransactionManager(IBWContext context)
 {
     _context = context;
 }
Esempio n. 17
0
 public BillPayManager(IBWContext context)
 {
     _context = context;
 }
Esempio n. 18
0
 public PayeeManager(IBWContext context)
 {
     _context = context;
 }
 public LoginController(IBWContext context)
 {
     _context = context;
 }