public async Task <IActionResult> Confirm(ATMFormModel model) { //methods to retrieve have to be different because int? vs int var account = await _acctRepo.Get(model.AccountNumber); var destAccount = await _acctRepo.GetDest(model.DestinationAccountNumber); var amount = model.Amount; string comment = model.Comment; switch (model.TransactionType) { case ("W"): NWBASystem.GetInstance().Withdraw(account, amount); break; case ("D"): NWBASystem.GetInstance().Deposit(account, amount); break; case ("T"): NWBASystem.GetInstance().Transfer(account, destAccount, amount, comment); break; } _acctRepo.Save(); return(RedirectToAction(nameof(Success))); }
public async Task ProcessInScope(IServiceProvider serviceProvider) { Console.WriteLine("Current Time: " + DateTime.Now); var bpayRepo = serviceProvider.GetService <BillpayManager>(); var accRepo = serviceProvider.GetService <AccountManager>(); var loginRepo = serviceProvider.GetService <LoginManager>(); BillPay billPay = await bpayRepo.GetEarliestBillPay(); if (billPay != null) { //Debugging Code - Ignore writelines Console.WriteLine("------\nDate looking for " + billPay.ScheduleDate.ToLocalTime() + "\nTime Difference: " + (billPay.ScheduleDate.ToLocalTime() - DateTime.Now) + "\nTime Equal: " + AreEqual(DateTime.Now, billPay.ScheduleDate.ToLocalTime()) + "\n------"); if (AreEqual(DateTime.Now, billPay.ScheduleDate.ToLocalTime())) { Account account = await accRepo.Get(billPay.AccountNumber); if (CanProceed(account, billPay.Amount)) { NWBASystem.GetInstance().PayBill(account, billPay.Amount, billPay.Payee); UpdateNextScheduledDate(billPay); if (DeleteBillPayIfNeeded(billPay)) { bpayRepo.Delete(billPay); } else { bpayRepo.Update(billPay); } } else { bpayRepo.Delete(billPay); } Console.WriteLine("Scheduled payment has been made!"); } } ; Login login = await loginRepo.GetEarliestBlockedAccount(); if (login != null) { Console.WriteLine("Time to unlock: " + login.BlockTime.ToLocalTime().AddSeconds(60)); if (AreEqual(DateTime.Now, login.BlockTime.ToLocalTime().AddSeconds(60))) { login.LoginAttempts = 0; login.Status = "Active"; loginRepo.Update(login); Console.WriteLine("Account unblocked"); } } }
public async Task <IActionResult> Confirm(BillPayFormModel model) { Account account = await _acctRepo.GetAcctBpay(model.SenderAccountNumber); Payee payee = await _payeeRepo.Get(model.DestinationID); NWBASystem.GetInstance().SchedulePayment(account, payee, model.Amount, model.Date, model.Period); _acctRepo.Save(); return(RedirectToAction(nameof(SuccessfulSchedule))); }